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
impl YangLibraryCache
Sourcepub fn from_disk(
cache_root_path: PathBuf,
) -> Result<Self, YangLibraryCacheError>
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.
Sourcepub fn put_yang_library(
&mut self,
subscription_info: SubscriptionInfo,
yang_lib: YangLibrary,
schemas: HashMap<Box<str>, Box<str>>,
) -> Result<Arc<YangLibraryReference>, YangLibraryCacheError>
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.
pub fn remove_by_content_id( &mut self, content_id: &ContentId, ) -> Result<(), YangLibraryCacheError>
pub fn remove_by_subscription_info( &mut self, subscription_info: &SubscriptionInfo, ) -> Result<Option<SubscriptionInfo>, YangLibraryCacheError>
pub fn get_by_subscription_info( &self, subscription_info: &SubscriptionInfo, ) -> Option<Arc<YangLibraryReference>>
pub fn get_by_content_id( &mut self, content_id: &ContentId, ) -> Option<Arc<YangLibraryReference>>
pub fn get_by_subscription_id( &self, peer_ip: IpAddr, subscription_id: SubscriptionId, ) -> Option<(SubscriptionInfo, Option<Arc<YangLibraryReference>>)>
Auto Trait Implementations§
impl Freeze for YangLibraryCache
impl RefUnwindSafe for YangLibraryCache
impl Send for YangLibraryCache
impl Sync for YangLibraryCache
impl Unpin for YangLibraryCache
impl UnsafeUnpin for YangLibraryCache
impl UnwindSafe for YangLibraryCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 more