pub struct CacheNamespace(/* private fields */);Expand description
A cache namespace.
Implementations§
Source§impl CacheNamespace
impl CacheNamespace
Sourcepub fn new(value: impl Into<String>) -> CacheNamespace
pub fn new(value: impl Into<String>) -> CacheNamespace
Creates a new string-backed primitive.
Examples found in repository?
examples/basic_usage.rs (line 15)
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}Trait Implementations§
Source§impl AsRef<str> for CacheNamespace
impl AsRef<str> for CacheNamespace
Source§impl Clone for CacheNamespace
impl Clone for CacheNamespace
Source§fn clone(&self) -> CacheNamespace
fn clone(&self) -> CacheNamespace
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CacheNamespace
impl Debug for CacheNamespace
Source§impl Default for CacheNamespace
impl Default for CacheNamespace
Source§fn default() -> CacheNamespace
fn default() -> CacheNamespace
Returns the “default value” for a type. Read more
Source§impl Display for CacheNamespace
impl Display for CacheNamespace
Source§impl From<&str> for CacheNamespace
impl From<&str> for CacheNamespace
Source§fn from(value: &str) -> CacheNamespace
fn from(value: &str) -> CacheNamespace
Converts to this type from the input type.
Source§impl From<String> for CacheNamespace
impl From<String> for CacheNamespace
Source§fn from(value: String) -> CacheNamespace
fn from(value: String) -> CacheNamespace
Converts to this type from the input type.
Source§impl Hash for CacheNamespace
impl Hash for CacheNamespace
Source§impl Ord for CacheNamespace
impl Ord for CacheNamespace
Source§fn cmp(&self, other: &CacheNamespace) -> Ordering
fn cmp(&self, other: &CacheNamespace) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for CacheNamespace
impl PartialEq for CacheNamespace
Source§fn eq(&self, other: &CacheNamespace) -> bool
fn eq(&self, other: &CacheNamespace) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for CacheNamespace
impl PartialOrd for CacheNamespace
impl Eq for CacheNamespace
impl StructuralPartialEq for CacheNamespace
Auto Trait Implementations§
impl Freeze for CacheNamespace
impl RefUnwindSafe for CacheNamespace
impl Send for CacheNamespace
impl Sync for CacheNamespace
impl Unpin for CacheNamespace
impl UnsafeUnpin for CacheNamespace
impl UnwindSafe for CacheNamespace
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