pub struct EngineCache { /* private fields */ }Expand description
Thread-safe cache of discovered engine state.
Use this to share engine discovery results across multiple clients targeting different engines.
§Example
ⓘ
let cache = EngineCache::new();
let client1 = Client::builder("192.168.1.1:161")
.username("admin")
.auth(AuthProtocol::Sha1, "authpass")
.engine_cache(cache.clone())
.connect()
.await?;
let client2 = Client::builder("192.168.1.2:161")
.username("admin")
.auth(AuthProtocol::Sha1, "authpass")
.engine_cache(cache.clone())
.connect()
.await?;Implementations§
Source§impl EngineCache
impl EngineCache
Sourcepub fn get(&self, target: &SocketAddr) -> Option<EngineState>
pub fn get(&self, target: &SocketAddr) -> Option<EngineState>
Get cached engine state for a target.
Sourcepub fn insert(&self, target: SocketAddr, state: EngineState)
pub fn insert(&self, target: SocketAddr, state: EngineState)
Store engine state for a target.
Sourcepub fn update_time(
&self,
target: &SocketAddr,
response_boots: u32,
response_time: u32,
) -> bool
pub fn update_time( &self, target: &SocketAddr, response_boots: u32, response_time: u32, ) -> bool
Update time for an existing entry.
Returns true if the entry was updated, false if not found or not updated.
Sourcepub fn remove(&self, target: &SocketAddr) -> Option<EngineState>
pub fn remove(&self, target: &SocketAddr) -> Option<EngineState>
Remove cached state for a target.
Trait Implementations§
Source§impl Clone for EngineCache
impl Clone for EngineCache
Source§impl Debug for EngineCache
impl Debug for EngineCache
Source§impl Default for EngineCache
impl Default for EngineCache
Source§fn default() -> EngineCache
fn default() -> EngineCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for EngineCache
impl RefUnwindSafe for EngineCache
impl Send for EngineCache
impl Sync for EngineCache
impl Unpin for EngineCache
impl UnwindSafe for EngineCache
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