MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / skip_value_depth

Function skip_value_depth

nodedb-query/src/msgpack_scan/reader.rs:92–195  ·  view source on GitHub ↗
(buf: &[u8], offset: usize, depth: u16)

Source from the content-addressed store, hash-verified

90}
91
92fn skip_value_depth(buf: &[u8], offset: usize, depth: u16) -> Option<usize> {
93 if depth > MAX_DEPTH {
94 return None;
95 }
96 let tag = get(buf, offset)?;
97 match tag {
98 // positive fixint (0x00..=0x7f)
99 0x00..=0x7f => Some(offset + 1),
100 // negative fixint (0xe0..=0xff)
101 0xe0..=0xff => Some(offset + 1),
102 // nil, false, true
103 NIL | FALSE | TRUE => Some(offset + 1),
104
105 // fixmap (0x80..=0x8f)
106 0x80..=0x8f => {
107 let count = (tag & 0x0f) as usize;
108 skip_n_pairs(buf, offset + 1, count, depth)
109 }
110 MAP16 => {
111 let count = read_u16_be(buf, offset + 1)? as usize;
112 skip_n_pairs(buf, offset + 3, count, depth)
113 }
114 MAP32 => {
115 let count = read_u32_be(buf, offset + 1)? as usize;
116 skip_n_pairs(buf, offset + 5, count, depth)
117 }
118
119 // fixarray (0x90..=0x9f)
120 0x90..=0x9f => {
121 let count = (tag & 0x0f) as usize;
122 skip_n_values(buf, offset + 1, count, depth)
123 }
124 ARRAY16 => {
125 let count = read_u16_be(buf, offset + 1)? as usize;
126 skip_n_values(buf, offset + 3, count, depth)
127 }
128 ARRAY32 => {
129 let count = read_u32_be(buf, offset + 1)? as usize;
130 skip_n_values(buf, offset + 5, count, depth)
131 }
132
133 // fixstr (0xa0..=0xbf)
134 0xa0..=0xbf => {
135 let len = (tag & 0x1f) as usize;
136 checked_advance(buf, offset, 1 + len)
137 }
138 STR8 => {
139 let len = get(buf, offset + 1)? as usize;
140 checked_advance(buf, offset, 2 + len)
141 }
142 STR16 => {
143 let len = read_u16_be(buf, offset + 1)? as usize;
144 checked_advance(buf, offset, 3 + len)
145 }
146 STR32 => {
147 let len = read_u32_be(buf, offset + 1)? as usize;
148 checked_advance(buf, offset, 5 + len)
149 }

Callers 3

skip_valueFunction · 0.85
skip_n_valuesFunction · 0.85
skip_n_pairsFunction · 0.85

Calls 6

getFunction · 0.85
skip_n_pairsFunction · 0.85
read_u16_beFunction · 0.85
read_u32_beFunction · 0.85
skip_n_valuesFunction · 0.85
checked_advanceFunction · 0.85

Tested by

no test coverage detected