make MAX_LEN local

This commit is contained in:
yggverse 2024-11-01 05:30:40 +02:00
parent 1b1ab6bea0
commit 5e315c0259

View file

@ -6,8 +6,6 @@ pub use error::Error;
use glib::GString; use glib::GString;
pub const MAX_LEN: usize = 0x400; // 1024
/// Meta **data** holder /// Meta **data** holder
/// ///
/// For example, `value` could contain: /// For example, `value` could contain:
@ -18,12 +16,17 @@ pub struct Data {
} }
impl Data { impl Data {
// Constructors
/// Parse meta **data** from UTF-8 buffer /// Parse meta **data** from UTF-8 buffer
/// from entire response or just header slice /// from entire response or just header slice
/// ///
/// * result could be `None` for some [status codes](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes) /// * result could be `None` for some [status codes](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes)
/// that does not expect any data in header /// that does not expect any data in header
pub fn from_utf8(buffer: &[u8]) -> Result<Option<Self>, Error> { pub fn from_utf8(buffer: &[u8]) -> Result<Option<Self>, Error> {
// Define max buffer length for this method
const MAX_LEN: usize = 0x400; // 1024
// Init bytes buffer // Init bytes buffer
let mut bytes: Vec<u8> = Vec::with_capacity(MAX_LEN); let mut bytes: Vec<u8> = Vec::with_capacity(MAX_LEN);
@ -56,6 +59,8 @@ impl Data {
} }
} }
// Getters
pub fn value(&self) -> &GString { pub fn value(&self) -> &GString {
&self.value &self.value
} }