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
impl KnowledgeObjectBuilder
Sourcepub fn new(kind: ObjectKind) -> Self
pub fn new(kind: ObjectKind) -> Self
Create a new builder with the given object kind.
Sourcepub fn attribute(self, key: impl Into<String>, value: SochValue) -> Self
pub fn attribute(self, key: impl Into<String>, value: SochValue) -> Self
Add a named attribute to the payload (creates/extends an Object payload).
Sourcepub fn edges(self, edges: impl IntoIterator<Item = Edge>) -> Self
pub fn edges(self, edges: impl IntoIterator<Item = Edge>) -> Self
Add multiple edges at once.
Sourcepub fn embedding(self, space: impl Into<String>, vector: Vec<f32>) -> Self
pub fn embedding(self, space: impl Into<String>, vector: Vec<f32>) -> Self
Add an embedding in a named space.
Sourcepub fn embedding_with_metadata(
self,
space: impl Into<String>,
vector: Vec<f32>,
model: impl Into<String>,
generated_at: u64,
) -> Self
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.
Sourcepub fn valid_from(self, valid_from: u64) -> Self
pub fn valid_from(self, valid_from: u64) -> Self
Set the valid_from time (HLC-encoded microseconds).
Sourcepub fn system_time(self, system_time: u64) -> Self
pub fn system_time(self, system_time: u64) -> Self
Set the system_time (typically assigned automatically by HLC on write).
Sourcepub fn temporal(self, temporal: BitemporalCoord) -> Self
pub fn temporal(self, temporal: BitemporalCoord) -> Self
Set the full bitemporal coordinate.
Sourcepub fn provenance(self, provenance: Provenance) -> Self
pub fn provenance(self, provenance: Provenance) -> Self
Set the provenance record.
Add multiple tags.
Sourcepub fn build(self) -> KnowledgeObject
pub fn build(self) -> KnowledgeObject
Build the Knowledge Object, computing the content-addressed OID.
Sourcepub fn build_with_oid(self, oid: ObjectId) -> KnowledgeObject
pub fn build_with_oid(self, oid: ObjectId) -> KnowledgeObject
Build with a pre-computed OID (for deserialization or migration).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KnowledgeObjectBuilder
impl RefUnwindSafe for KnowledgeObjectBuilder
impl Send for KnowledgeObjectBuilder
impl Sync for KnowledgeObjectBuilder
impl Unpin for KnowledgeObjectBuilder
impl UnsafeUnpin for KnowledgeObjectBuilder
impl UnwindSafe for KnowledgeObjectBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more