pub struct BytesCache { /* private fields */ }
Implementations§
Source§impl BytesCache
impl BytesCache
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn with_entry_size_limit(entry_size_limit: usize) -> Self
Sourcepub fn with_capacity_and_entry_size_limit(
capacity: usize,
entry_size_limit: usize,
) -> Result<Self, Error>
pub fn with_capacity_and_entry_size_limit( capacity: usize, entry_size_limit: usize, ) -> Result<Self, Error>
Helper to create a new bytes cache with both an individual entry and size limit.
§Errors
This function will return Error::EntrySizeLimitExceedsTotalCapacity
if the specified size is too large.
pub async fn get(&self, key: &str) -> Option<BytesCacheEntry>
pub async fn len(&self) -> usize
pub async fn is_empty(&self) -> bool
pub fn total_size(&self) -> usize
Sourcepub async fn set(
&mut self,
key: String,
bytes: Bytes,
) -> Result<Option<BytesCacheEntry>, Error>
pub async fn set( &mut self, key: String, bytes: Bytes, ) -> Result<Option<BytesCacheEntry>, Error>
Adds a image to the cache.
§Errors
This function will return an error if there is not enough free size.
pub fn pop(&mut self) -> Option<BytesCacheEntry>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BytesCache
impl RefUnwindSafe for BytesCache
impl Send for BytesCache
impl Sync for BytesCache
impl Unpin for BytesCache
impl UnwindSafe for BytesCache
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
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>
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 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>
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