pub struct WithEtag<T> { /* private fields */ }Expand description
A value paired with the ETag it was fetched with, for later use as an
If-Match precondition on an update.
Fields are pub(crate), not pub: every WithEtag a caller can observe
came from an actual get_* call in this crate, which is what makes the
ETag trustworthy as “this really was fetched, not typed in by hand.” A
pub struct literal would let a caller construct
WithEtag { value, etag: Some("whatever") } directly, defeating that
guarantee. Use WithEtag::value, WithEtag::etag, or
WithEtag::into_parts to get the data back out.
Implementations§
Source§impl<T> WithEtag<T>
impl<T> WithEtag<T>
Sourcepub fn etag(&self) -> Option<&str>
pub fn etag(&self) -> Option<&str>
The ETag it was fetched with, if the response carried one. Pass this
straight to the matching update_*/patch_* call’s etag
parameter (as Some(etag.as_deref())) for optimistic-concurrency
protection.
Sourcepub fn into_parts(self) -> (T, Option<String>)
pub fn into_parts(self) -> (T, Option<String>)
Consumes self, returning the value and ETag by ownership - useful
when you need to move value out (e.g. to mutate it in place
before sending it back as a new_definition) without cloning.