pub struct ExactMatchChecker {
recall: Arc<RecallService>,
}Expand description
Checker for exact content match via SHA256 hash.
§How it works
- Computes SHA256 hash of normalized content
- Converts hash to tag format:
hash:sha256:<16-char-prefix> - Searches for memories with matching tag in the specified namespace
- Returns the first matching memory ID if found
§Example
ⓘ
use subcog::services::deduplication::ExactMatchChecker;
use subcog::services::recall::RecallService;
use std::sync::Arc;
let recall = Arc::new(RecallService::default());
let checker = ExactMatchChecker::new(recall);
let result = checker.check("Use PostgreSQL for storage", Namespace::Decisions)?;
if let Some((memory_id, urn)) = result {
println!("Exact match found: {}", urn);
}Fields§
§recall: Arc<RecallService>Recall service for searching memories.
Implementations§
Source§impl ExactMatchChecker
impl ExactMatchChecker
Sourcepub const fn new(recall: Arc<RecallService>) -> Self
pub const fn new(recall: Arc<RecallService>) -> Self
Sourcepub fn check(
&self,
content: &str,
namespace: Namespace,
domain: &str,
) -> Result<Option<(MemoryId, String)>>
pub fn check( &self, content: &str, namespace: Namespace, domain: &str, ) -> Result<Option<(MemoryId, String)>>
Checks if content has an exact match in the given namespace.
§Arguments
content- The content to check for duplicatesnamespace- The namespace to search withindomain- The domain string for URN construction
§Returns
Returns Some((MemoryId, URN)) if an exact match is found, None otherwise.
§Errors
Returns an error if the search operation fails.
§Example
ⓘ
let result = checker.check("content", Namespace::Decisions, "project")?;
match result {
Some((id, urn)) => println!("Duplicate: {}", urn),
None => println!("No duplicate found"),
}Sourcepub fn content_to_tag(content: &str) -> String
pub fn content_to_tag(content: &str) -> String
Auto Trait Implementations§
impl Freeze for ExactMatchChecker
impl !RefUnwindSafe for ExactMatchChecker
impl Send for ExactMatchChecker
impl Sync for ExactMatchChecker
impl Unpin for ExactMatchChecker
impl !UnwindSafe for ExactMatchChecker
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].