pub struct Swap {
pub swap_record: Option<Option<String>>,
pub swap_commit: Option<String>,
}Expand description
The compare-and-swap fields, as they arrive on the wire.
Both are CIDs naming a version to swap against, and both are now
evaluated. Swap::resolve turns them into the preconditions the store
and the registry check; a CID that does not decode is refused there,
before anything is read, because it is a statement about the request
rather than about the repository.
Fields§
§swap_record: Option<Option<String>>Swap against the previous version of this record.
Nullable in the lexicon, so it is read as a double option: null
asserts the record does not exist, and absent asserts nothing.
swap_commit: Option<String>Swap against the repository’s current commit.
Implementations§
Source§impl Swap
impl Swap
Sourcepub fn resolve(&self) -> Result<Swap, ApiError>
pub fn resolve(&self) -> Result<Swap, ApiError>
The preconditions these fields ask for.
swapRecord: null is Precondition::Absent – the lexicon marks
the field nullable and null asserts the record does not exist yet –
and a CID is Precondition::Version. An absent field asserts
nothing, which is what leaving it out means.
Sourcepub fn resolve_commit_only(&self, route: &str) -> Result<Swap, ApiError>
pub fn resolve_commit_only(&self, route: &str) -> Result<Swap, ApiError>
The same, for a route whose lexicon declares only swapCommit.
createRecord and applyWrites have no swapRecord field. A body
carrying one is refused rather than ignored: a client that sent it
believes its write is conditional, and neither route has one key to
make it conditional on – applyWrites writes many records, and
createRecord is already conditional on the key being free.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Swap
impl<'de> Deserialize<'de> for Swap
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 Swap
impl StructuralPartialEq for Swap
Auto Trait Implementations§
impl Freeze for Swap
impl RefUnwindSafe for Swap
impl Send for Swap
impl Sync for Swap
impl Unpin for Swap
impl UnsafeUnpin for Swap
impl UnwindSafe for Swap
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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