Skip to main content

Doc

Struct Doc 

Source
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

Source

pub unsafe fn as_raw(&self) -> *mut zvec_doc_t

Returns the raw FFI handle.

§Safety

The caller must not use the handle after the Doc is dropped.

Source

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.

Source

pub fn new() -> Result<Self>

Creates a new empty document.

Source

pub fn set_pk(&mut self, pk: &str)

Sets the primary key.

Source

pub fn get_pk(&self) -> Option<&str>

Returns the primary key, or None if not set.

Source

pub fn get_score(&self) -> f32

Returns the document score (set by query results).

Source

pub fn field_count(&self) -> usize

Returns the number of fields in the document.

Source

pub fn is_empty(&self) -> bool

Returns whether the document is empty.

Source

pub fn has_field(&self, name: &str) -> bool

Returns whether the document contains the specified field.

Source

pub fn is_field_null(&self, name: &str) -> bool

Returns whether the specified field is null.

Source

pub fn add_string(&mut self, name: &str, value: &str) -> Result<()>

Adds a string field.

Source

pub fn add_bool(&mut self, name: &str, value: bool) -> Result<()>

Adds a boolean field.

Source

pub fn add_i32(&mut self, name: &str, value: i32) -> Result<()>

Adds an i32 field.

Source

pub fn add_i64(&mut self, name: &str, value: i64) -> Result<()>

Adds an i64 field.

Source

pub fn add_u32(&mut self, name: &str, value: u32) -> Result<()>

Adds a u32 field.

Source

pub fn add_u64(&mut self, name: &str, value: u64) -> Result<()>

Adds a u64 field.

Source

pub fn add_f32(&mut self, name: &str, value: f32) -> Result<()>

Adds an f32 field.

Source

pub fn add_f64(&mut self, name: &str, value: f64) -> Result<()>

Adds an f64 field.

Source

pub fn add_vector_f32(&mut self, name: &str, vector: &[f32]) -> Result<()>

Adds a dense FP32 vector field.

Source

pub fn add_vector_f64(&mut self, name: &str, vector: &[f64]) -> Result<()>

Adds a dense FP64 vector field.

Source

pub fn add_binary(&mut self, name: &str, value: &[u8]) -> Result<()>

Adds a binary (raw bytes) field.

Source

pub fn add_vector_i8(&mut self, name: &str, vector: &[i8]) -> Result<()>

Adds a dense INT8 vector field.

Source

pub fn add_vector_i16(&mut self, name: &str, vector: &[i16]) -> Result<()>

Adds a dense INT16 vector field.

Source

pub fn add_array_i32(&mut self, name: &str, values: &[i32]) -> Result<()>

Adds an array of i32 values.

Source

pub fn add_array_i64(&mut self, name: &str, values: &[i64]) -> Result<()>

Adds an array of i64 values.

Source

pub fn add_array_u32(&mut self, name: &str, values: &[u32]) -> Result<()>

Adds an array of u32 values.

Source

pub fn add_array_u64(&mut self, name: &str, values: &[u64]) -> Result<()>

Adds an array of u64 values.

Source

pub fn add_array_f32(&mut self, name: &str, values: &[f32]) -> Result<()>

Adds an array of f32 values.

Source

pub fn add_array_f64(&mut self, name: &str, values: &[f64]) -> Result<()>

Adds an array of f64 values.

Source

pub fn add_array_bool(&mut self, name: &str, values: &[bool]) -> Result<()>

Adds an array of boolean values.

Source

pub fn set_field_null(&mut self, name: &str) -> Result<()>

Sets a field to null.

Source

pub fn remove_field(&mut self, name: &str) -> Result<()>

Removes a field from the document.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_array_bool(&self, name: &str) -> Result<Option<Vec<bool>>>

Gets an array of boolean values. Returns Ok(None) if the field does not exist or is null.

Source

pub fn clear(&mut self)

Clears all fields from the document.

Trait Implementations§

Source§

impl Drop for Doc

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Send for Doc

§

impl !Sync for Doc

§

impl Freeze for Doc

§

impl RefUnwindSafe for Doc

§

impl Unpin for Doc

§

impl UnsafeUnpin for Doc

§

impl UnwindSafe for Doc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.