mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 09:05:45 +00:00
make MAX_LEN local
This commit is contained in:
parent
1b1ab6bea0
commit
5e315c0259
1 changed files with 7 additions and 2 deletions
|
|
@ -6,8 +6,6 @@ pub use error::Error;
|
|||
|
||||
use glib::GString;
|
||||
|
||||
pub const MAX_LEN: usize = 0x400; // 1024
|
||||
|
||||
/// Meta **data** holder
|
||||
///
|
||||
/// For example, `value` could contain:
|
||||
|
|
@ -18,12 +16,17 @@ pub struct Data {
|
|||
}
|
||||
|
||||
impl Data {
|
||||
// Constructors
|
||||
|
||||
/// Parse meta **data** from UTF-8 buffer
|
||||
/// from entire response or just header slice
|
||||
///
|
||||
/// * 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
|
||||
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
|
||||
let mut bytes: Vec<u8> = Vec::with_capacity(MAX_LEN);
|
||||
|
||||
|
|
@ -56,6 +59,8 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn value(&self) -> &GString {
|
||||
&self.value
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue