Skip to main content

KnowledgeObjectBuilder

Struct KnowledgeObjectBuilder 

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

Ergonomic builder for constructing Knowledge Objects.

The builder computes the content-addressed OID automatically on .build().

§Example

let ko = KnowledgeObjectBuilder::new(ObjectKind::Entity)
    .attribute("name", SochValue::Text("Alice".into()))
    .embedding("semantic", vec![0.1, 0.2, 0.3])
    .tag("person")
    .valid_from(1700000000_000000)
    .build();

Implementations§

Source§

impl KnowledgeObjectBuilder

Source

pub fn new(kind: ObjectKind) -> Self

Create a new builder with the given object kind.

Source

pub fn payload(self, payload: SochValue) -> Self

Set the full payload.

Source

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

Add a named attribute to the payload (creates/extends an Object payload).

Source

pub fn edge(self, edge: Edge) -> Self

Add an outgoing edge.

Source

pub fn edges(self, edges: impl IntoIterator<Item = Edge>) -> Self

Add multiple edges at once.

Source

pub fn embedding(self, space: impl Into<String>, vector: Vec<f32>) -> Self

Add an embedding in a named space.

Source

pub fn embedding_with_metadata( self, space: impl Into<String>, vector: Vec<f32>, model: impl Into<String>, generated_at: u64, ) -> Self

Add an embedding with full metadata.

Source

pub fn valid_from(self, valid_from: u64) -> Self

Set the valid_from time (HLC-encoded microseconds).

Source

pub fn valid_to(self, valid_to: u64) -> Self

Set the valid_to time (HLC-encoded microseconds).

Source

pub fn system_time(self, system_time: u64) -> Self

Set the system_time (typically assigned automatically by HLC on write).

Source

pub fn temporal(self, temporal: BitemporalCoord) -> Self

Set the full bitemporal coordinate.

Source

pub fn provenance(self, provenance: Provenance) -> Self

Set the provenance record.

Source

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

Set the namespace.

Source

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

Add a tag.

Source

pub fn tags(self, tags: impl IntoIterator<Item = impl Into<String>>) -> Self

Add multiple tags.

Source

pub fn build(self) -> KnowledgeObject

Build the Knowledge Object, computing the content-addressed OID.

Source

pub fn build_with_oid(self, oid: ObjectId) -> KnowledgeObject

Build with a pre-computed OID (for deserialization or migration).

Trait Implementations§

Source§

impl From<SochValue> for KnowledgeObjectBuilder

Source§

fn from(value: SochValue) -> Self

Convert a SochValue into a KnowledgeObject builder. The SochValue becomes the payload; kind defaults to Document.

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.