pub struct ReplaceBuilder { /* private fields */ }Expand description
A builder-style API for configuring a non-transactional replace.
Implementations§
Source§impl ReplaceBuilder
impl ReplaceBuilder
Sourcepub fn begin(self) -> Result<Replace, CacheError>
pub fn begin(self) -> Result<Replace, CacheError>
Begin the replace, returning a Replace for reading the object to be replaced (if it
exists) which is also used to provide the new replacement object.
A Replace gives access to the existing object, if one is stored, that may be used to
construct the replacement object. Use Replace::execute() to get a StreamingBody to
write the replacement object into. The existing object cannot be accessed after calling
Replace::execute().
For the replace to complete successfully, the object must be written into the
StreamingBody, and then StreamingBody::finish() must be called. If the
StreamingBody is dropped before calling StreamingBody::finish(), the replacement is
considered incomplete, and any concurrent lookups that may be reading from the object as it
is streamed into the cache may encounter a streaming error.
Sourcepub fn header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self
pub fn header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self
Sets a single-value header for looking up an existing object to replace, discarding any
previous values associated with the header name.
Note: These headers are narrowly useful for implementing cache lookups
incorporating the semantics of the HTTP Vary
header, but the APIs in
this module are not suitable for HTTP caching out-of-the-box. Future SDK
releases will contain an HTTP Cache API.
The headers act as additional factors in object selection, and the choice of which
headers to factor in is determined during insertion, via e.g.
crate::cache::core::InsertBuilder::vary_by. A lookup will succeed when there is at least one
cached item that matches lookup’s cache key, and all of the lookup’s headers included in the cache
items’ vary_by list match the corresponding headers in that cached item.
A typical example
is a cached HTTP response, where the request had an Accept-Encoding header. In that case,
the origin server may or may not decide on a given encoding, and whether that same response is
suitable for a request with a different (or missing) Accept-Encoding header is determined
by whether Accept-Encoding is listed in Vary header in the origin’s response.
Sourcepub fn header_values<'a>(
self,
name: impl ToHeaderName,
values: impl IntoIterator<Item = &'a HeaderValue>,
) -> Self
pub fn header_values<'a>( self, name: impl ToHeaderName, values: impl IntoIterator<Item = &'a HeaderValue>, ) -> Self
Sets a multi-value header for looking up an existing object to replace, discarding any
previous values associated with the header name.
Note: These headers are narrowly useful for implementing cache lookups
incorporating the semantics of the HTTP Vary
header, but the APIs in
this module are not suitable for HTTP caching out-of-the-box. Future SDK
releases will contain an HTTP Cache API.
The headers act as additional factors in object selection, and the choice of which
headers to factor in is determined during insertion, via e.g.
crate::cache::core::InsertBuilder::vary_by. A lookup will succeed when there is at least one
cached item that matches lookup’s cache key, and all of the lookup’s headers included in the cache
items’ vary_by list match the corresponding headers in that cached item.
A typical example
is a cached HTTP response, where the request had an Accept-Encoding header. In that case,
the origin server may or may not decide on a given encoding, and whether that same response is
suitable for a request with a different (or missing) Accept-Encoding header is determined
by whether Accept-Encoding is listed in Vary header in the origin’s response.
Sourcepub fn replace_strategy(self, strategy: ReplaceStrategy) -> Self
pub fn replace_strategy(self, strategy: ReplaceStrategy) -> Self
Sets the strategy for performing the replace.
See ReplaceStrategy for details.
Sourcepub fn always_use_requested_range(self) -> Self
pub fn always_use_requested_range(self) -> Self
Respect the range in to_stream_with_range even when the body length is not yet known.
When a cache item is Found, the length of the cached item may or may not be known:
- the item may be fully cached;
- the item may be streaming in, but have a known length; or
- the item may be streaming in progressively, without a known length.
By default (legacy behavior), if a range is specified but the length is not known, the contents of the entire item will be provided instead of the requested range.
always_use_requested_range indicates any cached item returned by this lookup should provide only the requested range,
regardless of whether the length is known. An invalid range will eventually return a read error, possibly after providing some data.
NOTE: In the future, the always_use_requested_range behavior will be the default, and this method will be removed.
Auto Trait Implementations§
impl !Freeze for ReplaceBuilder
impl RefUnwindSafe for ReplaceBuilder
impl Send for ReplaceBuilder
impl Sync for ReplaceBuilder
impl Unpin for ReplaceBuilder
impl UnsafeUnpin for ReplaceBuilder
impl UnwindSafe for ReplaceBuilder
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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