pub struct Precondition {
pub if_match: Option<StateEtag>,
pub expected_generation: Option<u64>,
}Expand description
Optimistic-concurrency precondition for a mutating request (#1). A request
may pin the prior ETag (If-Match), the prior generation, or both. An empty
precondition is an unconditional write (creates only — see the contract doc).
Fields§
§if_match: Option<StateEtag>§expected_generation: Option<u64>Implementations§
Source§impl Precondition
impl Precondition
Sourcepub fn matching(etag: StateEtag, generation: u64) -> Self
pub fn matching(etag: StateEtag, generation: u64) -> Self
Pin both the ETag and generation of the resource as currently observed.
Sourcepub fn is_conditional(&self) -> bool
pub fn is_conditional(&self) -> bool
True if the precondition pins prior state (an If-Match and/or an
expected generation). An empty precondition pins nothing.
Sourcepub fn check(
&self,
current_etag: &StateEtag,
current_generation: u64,
) -> Result<(), PreconditionError>
pub fn check( &self, current_etag: &StateEtag, current_generation: u64, ) -> Result<(), PreconditionError>
Check the precondition against the server’s current state for a guarded (update/restore/delete) write.
An empty precondition is rejected with PreconditionError::Required
rather than silently passing — a conditional write must pin prior state,
otherwise a stale or malformed client clobbers a newer generation. The
create-if-absent path does not call check; it is gated by an existence
check on the server (see the contract doc).
Trait Implementations§
Source§impl Clone for Precondition
impl Clone for Precondition
Source§fn clone(&self) -> Precondition
fn clone(&self) -> Precondition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Precondition
impl Debug for Precondition
Source§impl Default for Precondition
impl Default for Precondition
Source§fn default() -> Precondition
fn default() -> Precondition
Source§impl<'de> Deserialize<'de> for Precondition
impl<'de> Deserialize<'de> for Precondition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Precondition
Source§impl PartialEq for Precondition
impl PartialEq for Precondition
Source§fn eq(&self, other: &Precondition) -> bool
fn eq(&self, other: &Precondition) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Precondition
impl Serialize for Precondition
impl StructuralPartialEq for Precondition
Auto Trait Implementations§
impl Freeze for Precondition
impl RefUnwindSafe for Precondition
impl Send for Precondition
impl Sync for Precondition
impl Unpin for Precondition
impl UnsafeUnpin for Precondition
impl UnwindSafe for Precondition
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.