mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
add jsonb_obj jsonb_array
This commit is contained in:
parent
f42b62f43c
commit
252583cb1e
6 changed files with 140 additions and 117 deletions
|
@ -401,12 +401,26 @@ impl Jsonb {
|
|||
jsonb
|
||||
}
|
||||
|
||||
pub fn make_empty_obj(size: usize) -> Self {
|
||||
let mut jsonb = Self {
|
||||
data: Vec::with_capacity(size),
|
||||
};
|
||||
jsonb
|
||||
.write_element_header(0, ElementType::OBJECT, 0, false)
|
||||
.unwrap();
|
||||
jsonb
|
||||
}
|
||||
|
||||
pub fn append_to_array_unsafe(&mut self, data: &[u8]) {
|
||||
self.data.extend_from_slice(data);
|
||||
}
|
||||
|
||||
pub fn finalize_array_unsafe(&mut self) -> Result<()> {
|
||||
self.write_element_header(0, ElementType::ARRAY, self.len() - 1, false)?;
|
||||
pub fn append_jsonb_to_array(&mut self, mut data: Vec<u8>) {
|
||||
self.data.append(&mut data);
|
||||
}
|
||||
|
||||
pub fn finalize_unsafe(&mut self, element_type: ElementType) -> Result<()> {
|
||||
self.write_element_header(0, element_type, self.len() - 1, false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue