MemoryRecordBuilder

Struct MemoryRecordBuilder 

Source
pub struct MemoryRecordBuilder { /* private fields */ }
Expand description

Builder type used to assemble MemoryRecord instances safely.

Implementations§

Source§

impl MemoryRecordBuilder

Source

pub fn id(self, id: Uuid) -> Self

Overrides the record identifier.

Source

pub fn timestamp(self, timestamp: SystemTime) -> Self

Sets the timestamp for the record.

Source

pub fn tag(self, tag: impl Into<String>) -> MemoryResult<Self>

Adds a single tag after validating that it is not empty.

§Errors

Returns MemoryError::InvalidRecord when the tag is empty or whitespace.

Source

pub fn tags<I, S>(self, tags: I) -> MemoryResult<Self>
where I: IntoIterator<Item = S>, S: Into<String>,

Extends the record with multiple tags.

§Errors

Returns MemoryError::InvalidRecord if any supplied tag is empty.

Source

pub fn metadata(self, key: impl Into<String>, value: Value) -> Self

Adds metadata entry.

Source

pub fn merge_metadata(self, map: Map<String, Value>) -> Self

Adds a full metadata map, overwriting existing keys when duplicates occur.

Source

pub fn embedding(self, embedding: EmbeddingVector) -> Self

Attaches an embedding to the record.

Source

pub fn build(self) -> MemoryResult<MemoryRecord>

Finalises the builder and produces the record.

§Errors

Returns MemoryError when the builder state fails validation.

Trait Implementations§

Source§

impl Debug for MemoryRecordBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

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.