pub struct Urn {
domain: UrnComponent,
namespace: UrnComponent,
memory_id: Option<String>,
original: String,
}Expand description
A parsed Subcog URN.
URNs can represent either a specific memory or a filter pattern.
Fields§
§domain: UrnComponentDomain component (project, user, org, or wildcard).
namespace: UrnComponentNamespace component (decisions, learnings, etc., or wildcard).
memory_id: Option<String>Optional memory ID for specific lookups.
original: StringOriginal URN string for display.
Implementations§
Source§impl Urn
impl Urn
Sourcepub fn parse(s: &str) -> Result<Self>
pub fn parse(s: &str) -> Result<Self>
Parses a URN string.
§Errors
Returns an error if the string is not a valid Subcog URN.
§Examples
use subcog::models::Urn;
// Full URN with memory ID
let urn = Urn::parse("subcog://project/patterns/abc123")?;
// Namespace filter
let urn = Urn::parse("subcog://_/learnings")?;
// Domain filter
let urn = Urn::parse("subcog://user/_")?;Sourcefn parse_component(s: &str) -> UrnComponent
fn parse_component(s: &str) -> UrnComponent
Parses a component, treating _ or empty as wildcard.
Sourcepub fn try_parse(s: &str) -> Option<Self>
pub fn try_parse(s: &str) -> Option<Self>
Tries to parse a string as a URN, returning None if it’s not a URN.
This is useful for checking if a memory_id argument is a URN or a raw ID.
Sourcepub fn extract_memory_id(s: &str) -> &str
pub fn extract_memory_id(s: &str) -> &str
Extracts just the memory ID from a string that might be a URN.
If the string is a URN, returns the memory_id component (last path segment).
If the string is not a URN, returns it as-is (it’s already a raw ID).
Sourcepub fn extract_memory_id_owned(s: &str) -> Option<String>
pub fn extract_memory_id_owned(s: &str) -> Option<String>
Extracts just the memory ID from a string, returning owned String.
If the string is a URN with a memory_id, returns that ID.
If the string is a URN without a memory_id (filter), returns None.
If the string is not a URN, returns it as-is (it’s already a raw ID).
Sourcepub const fn is_specific(&self) -> bool
pub const fn is_specific(&self) -> bool
Returns true if this URN represents a specific memory (has a memory_id).
Sourcepub const fn is_filter(&self) -> bool
pub const fn is_filter(&self) -> bool
Returns true if this URN is a filter pattern (no memory_id, or has wildcards).
Sourcepub const fn domain(&self) -> &UrnComponent
pub const fn domain(&self) -> &UrnComponent
Returns the domain component.
Sourcepub fn domain_str(&self) -> Option<&str>
pub fn domain_str(&self) -> Option<&str>
Returns the domain as a string, if not a wildcard.
Sourcepub const fn namespace(&self) -> &UrnComponent
pub const fn namespace(&self) -> &UrnComponent
Returns the namespace component.
Sourcepub fn namespace_str(&self) -> Option<&str>
pub fn namespace_str(&self) -> Option<&str>
Returns the namespace as a string, if not a wildcard.
Sourcepub fn to_domain(&self) -> Result<Option<Domain>>
pub fn to_domain(&self) -> Result<Option<Domain>>
Converts the domain component to a Domain, if not a wildcard.
§Errors
Returns an error if the domain string is invalid.
Sourcepub fn to_namespace(&self) -> Option<Namespace>
pub fn to_namespace(&self) -> Option<Namespace>
Converts the namespace component to a Namespace, if not a wildcard.
Trait Implementations§
impl Eq for Urn
impl StructuralPartialEq for Urn
Auto Trait Implementations§
impl Freeze for Urn
impl RefUnwindSafe for Urn
impl Send for Urn
impl Sync for Urn
impl Unpin for Urn
impl UnwindSafe for Urn
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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>
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>
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>
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>,
Layered].§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.