Skip to main content

VectorSetClient

Struct VectorSetClient 

Source
pub struct VectorSetClient<'a, C> { /* private fields */ }
Available on crate feature vector only.
Expand description

High-level client for Vector Set operations, bound to a single key.

Holds a mutable borrow of an underlying RedisExecutor and a vector set key, exposing typed add/query/introspection operations over the elements of that set.

Implementations§

Source§

impl<'a, C: RedisExecutor> VectorSetClient<'a, C>

Source

pub fn new(conn: &'a mut C, key: impl Into<CommandArg>) -> Self

Create a new VectorSetClient for key, borrowing conn.

Source

pub async fn add( &mut self, vector: Vec<f32>, element: impl Into<CommandArg>, ) -> Result<bool, RedisError>

Add or update a vector element. Returns true if the element was newly added, false if an existing element was updated.

Source

pub async fn add_with_options( &mut self, vector: Vec<f32>, element: impl Into<CommandArg>, options: VAddOptions, ) -> Result<bool, RedisError>

Add or update a vector element with explicit VAddOptions.

Source

pub async fn remove( &mut self, element: impl Into<CommandArg>, ) -> Result<bool, RedisError>

Remove an element. Returns true if it existed and was removed.

Source

pub async fn search( &mut self, query: VectorQuery, ) -> Result<Vec<SimilarityResult>, RedisError>

Find the elements most similar to the query target.

Source

pub async fn embedding( &mut self, element: impl Into<CommandArg>, ) -> Result<Vec<f64>, RedisError>

Retrieve the embedding (vector) for an element.

Return the neighbour links of an element, with similarity scores.

Source

pub async fn random( &mut self, count: Option<i64>, ) -> Result<Vec<Bytes>, RedisError>

Return one or more random elements from the set. A negative count allows duplicates.

Source

pub async fn set_attr( &mut self, element: impl Into<CommandArg>, json: &str, ) -> Result<bool, RedisError>

Set a JSON attribute string on an element. Returns true on success.

Source

pub async fn get_attr( &mut self, element: impl Into<CommandArg>, ) -> Result<Option<String>, RedisError>

Get the JSON attribute string for an element, or None if unset.

Source

pub async fn del_attr( &mut self, element: impl Into<CommandArg>, ) -> Result<bool, RedisError>

Clear the attribute on an element. Redis has no VDELATTR, so this sets the attribute to the empty string via VSETATTR. Returns true if the element exists, false if it is not in the set.

Source

pub async fn cardinality(&mut self) -> Result<i64, RedisError>

Return the number of elements in the set.

Source

pub async fn dimensions(&mut self) -> Result<i64, RedisError>

Return the dimensionality of the vectors in the set.

Source

pub async fn info(&mut self) -> Result<VectorSetInfo, RedisError>

Return structured information about the set.

Source

pub async fn set_attr_typed<T: Serialize>( &mut self, element: impl Into<CommandArg>, attr: &T, ) -> Result<bool, RedisError>

Available on crate feature serde only.

Set a typed attribute on an element, serializing with serde_json.

Source

pub async fn get_attr_typed<T: DeserializeOwned>( &mut self, element: impl Into<CommandArg>, ) -> Result<Option<T>, RedisError>

Available on crate feature serde only.

Get a typed attribute from an element, deserializing with serde_json. Returns None if no attribute is set.

Auto Trait Implementations§

§

impl<'a, C> !Freeze for VectorSetClient<'a, C>

§

impl<'a, C> !UnwindSafe for VectorSetClient<'a, C>

§

impl<'a, C> RefUnwindSafe for VectorSetClient<'a, C>

§

impl<'a, C> Send for VectorSetClient<'a, C>
where &'a mut C: Send,

§

impl<'a, C> Sync for VectorSetClient<'a, C>
where &'a mut C: Sync,

§

impl<'a, C> Unpin for VectorSetClient<'a, C>

§

impl<'a, C> UnsafeUnpin for VectorSetClient<'a, C>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more