Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ciborium/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ where
return match self.decoder.pull()? {
Header::Tag(..) => continue,

Header::Bytes(Some(len)) if len <= self.scratch.len() => {
Header::Text(Some(len)) | Header::Bytes(Some(len)) if len <= self.scratch.len() => {
self.decoder.read_exact(&mut self.scratch[..len])?;
visitor.visit_bytes(&self.scratch[..len])
}
Expand Down Expand Up @@ -428,6 +428,19 @@ where
visitor.visit_byte_buf(buffer)
}

Header::Text(len) => {
let mut buffer = String::new();

let mut segments = self.decoder.text(len);
while let Some(mut segment) = segments.pull()? {
while let Some(chunk) = segment.pull(self.scratch)? {
buffer.push_str(chunk);
}
}

visitor.visit_byte_buf(buffer.into_bytes())
}

Header::Array(len) => self.recurse(|me| {
let access = Access(me, len);
visitor.visit_seq(access)
Expand Down
Loading