mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
decode header bytes only
This commit is contained in:
parent
6dbf49cea3
commit
ab8eb402a8
6 changed files with 61 additions and 17 deletions
|
|
@ -14,7 +14,14 @@ impl Success {
|
|||
/// Create new `Self` from buffer include header bytes
|
||||
pub fn from_utf8(buffer: &[u8]) -> Result<Self, Error> {
|
||||
use std::str::FromStr;
|
||||
match std::str::from_utf8(buffer) {
|
||||
let len = buffer.len();
|
||||
match std::str::from_utf8(
|
||||
&buffer[..if len > super::HEADER_LEN {
|
||||
super::HEADER_LEN
|
||||
} else {
|
||||
len
|
||||
}],
|
||||
) {
|
||||
Ok(header) => Self::from_str(header),
|
||||
Err(e) => Err(Error::Utf8Error(e)),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue