mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2024-11-05 17:33:58 +03:00
fix: update daletpack spec impl
This commit is contained in:
parent
5a42997045
commit
91e185df0b
2 changed files with 6 additions and 16 deletions
|
@ -33,18 +33,9 @@ fn write_str(bv: &mut Vec<u8>, string: &String) -> Result<(), DaletPackError> {
|
|||
return Err(DaletPackError::StrMaxSizeExceeded);
|
||||
}
|
||||
|
||||
if size <= 256 {
|
||||
bv.push(TypeId::Str8 as u8);
|
||||
bv.push((size - 1) as u8);
|
||||
} else if size <= 65536 {
|
||||
bv.push(TypeId::Str16 as u8);
|
||||
bv.extend(((size - 1) as u16).to_be_bytes());
|
||||
} else {
|
||||
bv.push(TypeId::Str32 as u8);
|
||||
bv.extend(((size - 1) as u32).to_be_bytes());
|
||||
}
|
||||
|
||||
bv.push(TypeId::Str as u8);
|
||||
bv.extend_from_slice(string.as_bytes());
|
||||
bv.push(TypeId::StrEnd as u8);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -14,13 +14,12 @@ pub enum DaletPackError {
|
|||
#[derive(Debug, Clone, PartialEq, Eq, TryFromPrimitive, Copy)]
|
||||
#[repr(u8)]
|
||||
pub enum TypeId {
|
||||
Int8 = 1,
|
||||
Str8 = 4,
|
||||
Str16,
|
||||
Str32,
|
||||
StrEnd = 0,
|
||||
Str,
|
||||
Int8,
|
||||
TagArray,
|
||||
TagArrayEnd,
|
||||
TagId = 12,
|
||||
TagId,
|
||||
TagIdBody,
|
||||
TagIdArgument,
|
||||
TagIdBodyArgument,
|
||||
|
|
Loading…
Reference in a new issue