pub struct PatchSet { /* private fields */ }Expand description
A set of document patch operations.
Implementations§
Source§impl PatchSet
impl PatchSet
Sourcepub fn new(operations: Vec<PatchOperation>) -> PatchSet
pub fn new(operations: Vec<PatchOperation>) -> PatchSet
Creates a patch set from operations.
Examples found in repository?
examples/basic_usage.rs (lines 9-12)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let collection = CollectionName::new("customers");
8 let document_id = DocumentId::new("customer_123");
9 let patch = PatchSet::new(vec![PatchOperation::set(
10 DocumentPath::new("profile.display_name"),
11 "Joshua Whalen",
12 )]);
13
14 let key = CacheKey::builder()
15 .namespace(CacheNamespace::new("reviews"))
16 .segment("google-business-profile")
17 .segment("location")
18 .segment("fort-wayne")
19 .segment("summary")
20 .build();
21
22 let record = VectorRecord::new(
23 VectorId::new("review_789_embedding"),
24 Embedding::new(vec![0.012, -0.032, 0.481]),
25 )
26 .with_dimension(VectorDimension::new(3))?
27 .with_similarity_metric(SimilarityMetric::Cosine);
28
29 assert_eq!(collection.as_str(), "customers");
30 assert_eq!(document_id.as_str(), "customer_123");
31 assert_eq!(patch.operations().len(), 1);
32 assert_eq!(
33 key.to_string(),
34 "reviews:google-business-profile:location:fort-wayne:summary"
35 );
36 assert_eq!(record.dimension(), Some(VectorDimension::new(3)));
37
38 Ok(())
39}Sourcepub fn operations(&self) -> &[PatchOperation]
pub fn operations(&self) -> &[PatchOperation]
Returns the patch operations.
Examples found in repository?
examples/basic_usage.rs (line 31)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let collection = CollectionName::new("customers");
8 let document_id = DocumentId::new("customer_123");
9 let patch = PatchSet::new(vec![PatchOperation::set(
10 DocumentPath::new("profile.display_name"),
11 "Joshua Whalen",
12 )]);
13
14 let key = CacheKey::builder()
15 .namespace(CacheNamespace::new("reviews"))
16 .segment("google-business-profile")
17 .segment("location")
18 .segment("fort-wayne")
19 .segment("summary")
20 .build();
21
22 let record = VectorRecord::new(
23 VectorId::new("review_789_embedding"),
24 Embedding::new(vec![0.012, -0.032, 0.481]),
25 )
26 .with_dimension(VectorDimension::new(3))?
27 .with_similarity_metric(SimilarityMetric::Cosine);
28
29 assert_eq!(collection.as_str(), "customers");
30 assert_eq!(document_id.as_str(), "customer_123");
31 assert_eq!(patch.operations().len(), 1);
32 assert_eq!(
33 key.to_string(),
34 "reviews:google-business-profile:location:fort-wayne:summary"
35 );
36 assert_eq!(record.dimension(), Some(VectorDimension::new(3)));
37
38 Ok(())
39}Sourcepub fn with_operation(self, operation: PatchOperation) -> PatchSet
pub fn with_operation(self, operation: PatchOperation) -> PatchSet
Adds one operation.
Trait Implementations§
impl Eq for PatchSet
impl StructuralPartialEq for PatchSet
Auto Trait Implementations§
impl Freeze for PatchSet
impl RefUnwindSafe for PatchSet
impl Send for PatchSet
impl Sync for PatchSet
impl Unpin for PatchSet
impl UnsafeUnpin for PatchSet
impl UnwindSafe for PatchSet
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