pub struct MemoryScope {
pub level: ScopeLevel,
pub path: String,
}Expand description
A memory scope with a path-based address.
The path format mirrors a URI path, e.g.:
"global", "global/org:acme", "global/org:acme/user:alice".
Fields§
§level: ScopeLevel§path: StringImplementations§
Source§impl MemoryScope
impl MemoryScope
Sourcepub fn new(level: ScopeLevel, path: impl Into<String>) -> Result<Self>
pub fn new(level: ScopeLevel, path: impl Into<String>) -> Result<Self>
Create a new scope, validating that the path depth matches the level.
Sourcepub fn parse(path: &str) -> Result<Self>
pub fn parse(path: &str) -> Result<Self>
Parse a path string into a MemoryScope.
The level is inferred from the number of /-separated segments:
1 → Global, 2 → Org, 3 → User, 4 → Session, 5 → Agent.
Sourcepub fn parent(&self) -> Option<MemoryScope>
pub fn parent(&self) -> Option<MemoryScope>
Return the immediate parent scope, or None for the Global scope.
Sourcepub fn ancestors(&self) -> Vec<MemoryScope>
pub fn ancestors(&self) -> Vec<MemoryScope>
Return all ancestor scopes from the immediate parent up to (and including) the Global scope. Order: closest ancestor first.
Sourcepub fn contains(&self, other: &MemoryScope) -> bool
pub fn contains(&self, other: &MemoryScope) -> bool
Returns true if self is an ancestor of (or equal to) other.
Equivalently: self “contains” other if other.path starts with
self.path followed by / (or is identical).
Trait Implementations§
Source§impl Clone for MemoryScope
impl Clone for MemoryScope
Source§fn clone(&self) -> MemoryScope
fn clone(&self) -> MemoryScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryScope
impl Debug for MemoryScope
Source§impl<'de> Deserialize<'de> for MemoryScope
impl<'de> Deserialize<'de> for MemoryScope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for MemoryScope
impl Display for MemoryScope
Source§impl Hash for MemoryScope
impl Hash for MemoryScope
Source§impl PartialEq for MemoryScope
impl PartialEq for MemoryScope
Source§impl Serialize for MemoryScope
impl Serialize for MemoryScope
impl Eq for MemoryScope
impl StructuralPartialEq for MemoryScope
Auto Trait Implementations§
impl Freeze for MemoryScope
impl RefUnwindSafe for MemoryScope
impl Send for MemoryScope
impl Sync for MemoryScope
impl Unpin for MemoryScope
impl UnsafeUnpin for MemoryScope
impl UnwindSafe for MemoryScope
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.