pub struct MemoizedTransport<T: Transport> { /* private fields */ }Expand description
Memoized transport wrapper with LRU eviction.
Wraps any Transport implementation and caches the results of
one-shot send calls. Persistent connections (connect) are
forwarded directly to the inner transport without caching.
Implementations§
Source§impl<T: Transport> MemoizedTransport<T>
impl<T: Transport> MemoizedTransport<T>
Sourcepub fn new(inner: T, config: MemoConfig) -> Self
pub fn new(inner: T, config: MemoConfig) -> Self
Create a new memoized transport wrapping inner with the given config.
Sourcepub fn compute_cache_key(destination: &str, payload: &[u8]) -> [u8; 32]
pub fn compute_cache_key(destination: &str, payload: &[u8]) -> [u8; 32]
Compute the cache key as SHA-256(destination || payload).
Sourcepub fn invalidate(&self, key: &[u8; 32])
pub fn invalidate(&self, key: &[u8; 32])
Invalidate a specific cache entry by key.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Invalidate all cached entries.
Trait Implementations§
Source§impl<T: Transport> Transport for MemoizedTransport<T>
impl<T: Transport> Transport for MemoizedTransport<T>
Source§fn send(
&self,
destination: &str,
payload: &[u8],
) -> Result<Vec<u8>, TransportError>
fn send( &self, destination: &str, payload: &[u8], ) -> Result<Vec<u8>, TransportError>
Send a payload to
destination and return the response. Read moreSource§fn connect(
&self,
destination: &str,
) -> Result<Box<dyn Connection>, TransportError>
fn connect( &self, destination: &str, ) -> Result<Box<dyn Connection>, TransportError>
Establish a persistent connection to
destination.Auto Trait Implementations§
impl<T> !Freeze for MemoizedTransport<T>
impl<T> RefUnwindSafe for MemoizedTransport<T>where
T: RefUnwindSafe,
impl<T> Send for MemoizedTransport<T>
impl<T> Sync for MemoizedTransport<T>
impl<T> Unpin for MemoizedTransport<T>where
T: Unpin,
impl<T> UnsafeUnpin for MemoizedTransport<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for MemoizedTransport<T>where
T: UnwindSafe,
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