pub struct Doc { /* private fields */ }Expand description
A document in a zvec collection.
Documents contain typed fields and are used for both writing data to and reading data from collections.
Implementations§
Source§impl Doc
impl Doc
Sourcepub unsafe fn as_raw(&self) -> *mut zvec_doc_t
pub unsafe fn as_raw(&self) -> *mut zvec_doc_t
Sourcepub unsafe fn from_raw(handle: *mut zvec_doc_t) -> Self
pub unsafe fn from_raw(handle: *mut zvec_doc_t) -> Self
Creates an owning Doc from a raw FFI handle.
§Safety
The caller must ensure the handle is valid and was created by the zvec C API.
The Doc takes ownership and will call zvec_doc_destroy on drop.
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Returns the number of fields in the document.
Sourcepub fn has_field(&self, name: &str) -> bool
pub fn has_field(&self, name: &str) -> bool
Returns whether the document contains the specified field.
Sourcepub fn is_field_null(&self, name: &str) -> bool
pub fn is_field_null(&self, name: &str) -> bool
Returns whether the specified field is null.
Sourcepub fn add_vector_f32(&mut self, name: &str, vector: &[f32]) -> Result<()>
pub fn add_vector_f32(&mut self, name: &str, vector: &[f32]) -> Result<()>
Adds a dense FP32 vector field.
Sourcepub fn add_vector_f64(&mut self, name: &str, vector: &[f64]) -> Result<()>
pub fn add_vector_f64(&mut self, name: &str, vector: &[f64]) -> Result<()>
Adds a dense FP64 vector field.
Sourcepub fn add_binary(&mut self, name: &str, value: &[u8]) -> Result<()>
pub fn add_binary(&mut self, name: &str, value: &[u8]) -> Result<()>
Adds a binary (raw bytes) field.
Sourcepub fn add_vector_i8(&mut self, name: &str, vector: &[i8]) -> Result<()>
pub fn add_vector_i8(&mut self, name: &str, vector: &[i8]) -> Result<()>
Adds a dense INT8 vector field.
Sourcepub fn add_vector_i16(&mut self, name: &str, vector: &[i16]) -> Result<()>
pub fn add_vector_i16(&mut self, name: &str, vector: &[i16]) -> Result<()>
Adds a dense INT16 vector field.
Sourcepub fn add_array_i32(&mut self, name: &str, values: &[i32]) -> Result<()>
pub fn add_array_i32(&mut self, name: &str, values: &[i32]) -> Result<()>
Adds an array of i32 values.
Sourcepub fn add_array_i64(&mut self, name: &str, values: &[i64]) -> Result<()>
pub fn add_array_i64(&mut self, name: &str, values: &[i64]) -> Result<()>
Adds an array of i64 values.
Sourcepub fn add_array_u32(&mut self, name: &str, values: &[u32]) -> Result<()>
pub fn add_array_u32(&mut self, name: &str, values: &[u32]) -> Result<()>
Adds an array of u32 values.
Sourcepub fn add_array_u64(&mut self, name: &str, values: &[u64]) -> Result<()>
pub fn add_array_u64(&mut self, name: &str, values: &[u64]) -> Result<()>
Adds an array of u64 values.
Sourcepub fn add_array_f32(&mut self, name: &str, values: &[f32]) -> Result<()>
pub fn add_array_f32(&mut self, name: &str, values: &[f32]) -> Result<()>
Adds an array of f32 values.
Sourcepub fn add_array_f64(&mut self, name: &str, values: &[f64]) -> Result<()>
pub fn add_array_f64(&mut self, name: &str, values: &[f64]) -> Result<()>
Adds an array of f64 values.
Sourcepub fn add_array_bool(&mut self, name: &str, values: &[bool]) -> Result<()>
pub fn add_array_bool(&mut self, name: &str, values: &[bool]) -> Result<()>
Adds an array of boolean values.
Sourcepub fn set_field_null(&mut self, name: &str) -> Result<()>
pub fn set_field_null(&mut self, name: &str) -> Result<()>
Sets a field to null.
Sourcepub fn remove_field(&mut self, name: &str) -> Result<()>
pub fn remove_field(&mut self, name: &str) -> Result<()>
Removes a field from the document.
Sourcepub fn get_string(&self, name: &str) -> Result<Option<String>>
pub fn get_string(&self, name: &str) -> Result<Option<String>>
Gets a string field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_bool(&self, name: &str) -> Result<Option<bool>>
pub fn get_bool(&self, name: &str) -> Result<Option<bool>>
Gets a boolean field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_i32(&self, name: &str) -> Result<Option<i32>>
pub fn get_i32(&self, name: &str) -> Result<Option<i32>>
Gets an i32 field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_i64(&self, name: &str) -> Result<Option<i64>>
pub fn get_i64(&self, name: &str) -> Result<Option<i64>>
Gets an i64 field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_u32(&self, name: &str) -> Result<Option<u32>>
pub fn get_u32(&self, name: &str) -> Result<Option<u32>>
Gets a u32 field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_u64(&self, name: &str) -> Result<Option<u64>>
pub fn get_u64(&self, name: &str) -> Result<Option<u64>>
Gets a u64 field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_f32(&self, name: &str) -> Result<Option<f32>>
pub fn get_f32(&self, name: &str) -> Result<Option<f32>>
Gets an f32 field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_f64(&self, name: &str) -> Result<Option<f64>>
pub fn get_f64(&self, name: &str) -> Result<Option<f64>>
Gets an f64 field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_vector_f32(&self, name: &str) -> Result<Option<Vec<f32>>>
pub fn get_vector_f32(&self, name: &str) -> Result<Option<Vec<f32>>>
Gets a dense FP32 vector field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_vector_f64(&self, name: &str) -> Result<Option<Vec<f64>>>
pub fn get_vector_f64(&self, name: &str) -> Result<Option<Vec<f64>>>
Gets a dense FP64 vector field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_binary(&self, name: &str) -> Result<Option<Vec<u8>>>
pub fn get_binary(&self, name: &str) -> Result<Option<Vec<u8>>>
Gets a binary (raw bytes) field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_vector_i8(&self, name: &str) -> Result<Option<Vec<i8>>>
pub fn get_vector_i8(&self, name: &str) -> Result<Option<Vec<i8>>>
Gets a dense INT8 vector field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_vector_i16(&self, name: &str) -> Result<Option<Vec<i16>>>
pub fn get_vector_i16(&self, name: &str) -> Result<Option<Vec<i16>>>
Gets a dense INT16 vector field value. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_array_i32(&self, name: &str) -> Result<Option<Vec<i32>>>
pub fn get_array_i32(&self, name: &str) -> Result<Option<Vec<i32>>>
Gets an array of i32 values. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_array_i64(&self, name: &str) -> Result<Option<Vec<i64>>>
pub fn get_array_i64(&self, name: &str) -> Result<Option<Vec<i64>>>
Gets an array of i64 values. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_array_u32(&self, name: &str) -> Result<Option<Vec<u32>>>
pub fn get_array_u32(&self, name: &str) -> Result<Option<Vec<u32>>>
Gets an array of u32 values. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_array_u64(&self, name: &str) -> Result<Option<Vec<u64>>>
pub fn get_array_u64(&self, name: &str) -> Result<Option<Vec<u64>>>
Gets an array of u64 values. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_array_f32(&self, name: &str) -> Result<Option<Vec<f32>>>
pub fn get_array_f32(&self, name: &str) -> Result<Option<Vec<f32>>>
Gets an array of f32 values. Returns Ok(None) if the field does not exist or is null.
Sourcepub fn get_array_f64(&self, name: &str) -> Result<Option<Vec<f64>>>
pub fn get_array_f64(&self, name: &str) -> Result<Option<Vec<f64>>>
Gets an array of f64 values. Returns Ok(None) if the field does not exist or is null.