Skip to content

Commit

Permalink
feat(msgpack): add support for STR8 header
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 6, 2024
1 parent db9a2ef commit cd634ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/protocol/msgpack/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use super::{
value::Value, MsgPack, ARRAY16, ARRAY32, FALSE, FIXARRAY_MASK, FIXARRAY_SIZE_MASK,
FIXARRAY_VALUE, FIXMAP_MASK, FIXMAP_SIZE_MASK, FIXMAP_VALUE, FIXSTR_MASK, FIXSTR_SIZE_MASK,
FIXSTR_VALUE, FLOAT32, FLOAT64, INT16, INT32, INT64, INT8, MAP16, MAP32, NEGATIVE_FIXINT_MASK,
NEGATIVE_FIXINT_VALUE, NIL, POSITIVE_FIXINT_MASK, POSITIVE_FIXINT_VALUE, STR16, STR32, TRUE,
UINT16, UINT32, UINT64, UINT8,
NEGATIVE_FIXINT_VALUE, NIL, POSITIVE_FIXINT_MASK, POSITIVE_FIXINT_VALUE, STR16, STR32, STR8,
TRUE, UINT16, UINT32, UINT64, UINT8,
};
use crate::protocol::error::ProtocolError;
use std::collections::HashMap;
Expand Down Expand Up @@ -45,6 +45,11 @@ impl MsgPack {
Self::parse_str(input, pos, len)
}

STR8 => {
let len = input[*pos] as usize;
*pos += 1;
Self::parse_str(input, pos, len)
}
STR16 => {
let len = Self::parse_u16(input, pos)? as usize;
Self::parse_str(input, pos, len)
Expand Down
1 change: 1 addition & 0 deletions src/protocol/msgpack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub const INT32: u8 = 0xd2;
pub const INT64: u8 = 0xd3;
pub const FLOAT32: u8 = 0xca;
pub const FLOAT64: u8 = 0xcb;
pub const STR8: u8 = 0xd9;
pub const STR16: u8 = 0xda;
pub const STR32: u8 = 0xdb;
pub const ARRAY16: u8 = 0xdc;
Expand Down

0 comments on commit cd634ea

Please sign in to comment.