pub struct CachedBody {
pub representations: FastHashMap<Encoding, Bytes>,
}
Expand description
Cached HTTP response body.
Fields§
§representations: FastHashMap<Encoding, Bytes>
Representations.
Implementations§
Source§impl CachedBody
impl CachedBody
Sourcepub async fn new_with(
bytes: Bytes,
encoding: Encoding,
preferred_encoding: Encoding,
configuration: &EncodingConfiguration,
) -> Result<Self>
pub async fn new_with( bytes: Bytes, encoding: Encoding, preferred_encoding: Encoding, configuration: &EncodingConfiguration, ) -> Result<Self>
Constructor with an initial representation.
If the preferred_encoding
is different from the encoding
then we will reencode.
If an Identity is created during this reencoding then it will also be
stored if keep_identity_encoding
is true.
Sourcepub async fn get(
&self,
encoding: &Encoding,
configuration: &EncodingConfiguration,
) -> Result<(Bytes, Option<Self>)>
pub async fn get( &self, encoding: &Encoding, configuration: &EncodingConfiguration, ) -> Result<(Bytes, Option<Self>)>
Returns the body Bytes in the specified encoding.
If we don’t have the specified encoding then we will reencode from another encoding, storing the result so that we won’t have to encode it again.
If an Identity is created during this reencoding then it will also be
stored if keep_identity_encoding
is true.
Returns a modified clone if reencoding caused a new encoding to be stored. Note that cloning should be cheap due to our use of Bytes.
Trait Implementations§
Source§impl CacheWeight for CachedBody
impl CacheWeight for CachedBody
Source§fn cache_weight(&self) -> usize
fn cache_weight(&self) -> usize
Cache weight as a byte count. Read more
Source§impl Clone for CachedBody
impl Clone for CachedBody
Source§fn clone(&self) -> CachedBody
fn clone(&self) -> CachedBody
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for CachedBody
impl RefUnwindSafe for CachedBody
impl Send for CachedBody
impl Sync for CachedBody
impl Unpin for CachedBody
impl UnwindSafe for CachedBody
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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