Skip to main content

YangLibraryCache

Struct YangLibraryCache 

Source
pub struct YangLibraryCache { /* private fields */ }
Expand description

Cache for YANG library references used by a YANG-Push collector.

YangLibraryCache provides efficient lookup of YANG library references through two indexing strategies:

  • Content ID index: Direct O(1) lookup when the content identifier is known
  • Subscription info index: Lookup by the full subscription context (peer, XPath, modules)

In addition, it maintains a mapping of subscription IDs per peer IP address to facilitate lookups based on subscription ID to get the associated SubscriptionInfo. This is useful when processing that has the subscription started message read in the past and only received the period notifications.

The cache supports both in-memory creation and restoration from persistent disk storage. See the module documentation for the disk storage layout and detailed usage examples.

Implementations§

Source§

impl YangLibraryCache

Source

pub fn new(cache_root_path: PathBuf) -> Self

Create a new, empty YANG Library Cache.

Source

pub fn from_disk( cache_root_path: PathBuf, ) -> Result<Self, YangLibraryCacheError>

Load an existing YANG Library Cache from disk. The cache is populated by reading all YANG library entries stored under the given root path.

The YANG modules are loaded for each YANG Library reference to verify they are correctly stored.

Source

pub fn put_yang_library( &mut self, subscription_info: SubscriptionInfo, yang_lib: YangLibrary, schemas: HashMap<Box<str>, Box<str>>, ) -> Result<Arc<YangLibraryReference>, YangLibraryCacheError>

Store a YANG Library along with its associated Subscription Info and schemas into the cache and persist them to disk.

If the YANG Library already exists in the cache and is identical, the existing reference is returned and the subscription info is appended.

Source

pub fn remove_by_content_id( &mut self, content_id: &ContentId, ) -> Result<(), YangLibraryCacheError>

Source

pub fn remove_by_subscription_info( &mut self, subscription_info: &SubscriptionInfo, ) -> Result<Option<SubscriptionInfo>, YangLibraryCacheError>

Source

pub fn get_by_subscription_info( &self, subscription_info: &SubscriptionInfo, ) -> Option<Arc<YangLibraryReference>>

Source

pub fn get_by_content_id( &mut self, content_id: &ContentId, ) -> Option<Arc<YangLibraryReference>>

Source

pub fn get_by_subscription_id( &self, peer_ip: IpAddr, subscription_id: SubscriptionId, ) -> Option<(SubscriptionInfo, Option<Arc<YangLibraryReference>>)>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more