Struct Commit

Source
pub struct Commit {
    pub subject: String,
    pub created_at: i64,
    pub signer: String,
    pub set: Option<HashMap<String, Value>>,
    pub remove: Option<Vec<String>>,
    pub destroy: Option<bool>,
    pub signature: Option<String>,
    pub push: Option<HashMap<String, Value>>,
    pub previous_commit: Option<String>,
    pub url: Option<String>,
}
Expand description

A Commit is a set of changes to a Resource. Use CommitBuilder if you’re programmatically constructing a Delta.

Fields§

§subject: String

The subject URL that is to be modified by this Delta

§created_at: i64

The date it was created, as a unix timestamp

§signer: String

The URL of the one signing this Commit

§set: Option<HashMap<String, Value>>

The set of PropVals that need to be added. Overwrites existing values

§remove: Option<Vec<String>>

The set of property URLs that need to be removed

§destroy: Option<bool>

If set to true, deletes the entire resource

§signature: Option<String>

Base64 encoded signature of the JSON serialized Commit

§push: Option<HashMap<String, Value>>

List of Properties and Arrays to be appended to them

§previous_commit: Option<String>

The previously applied commit to this Resource.

§url: Option<String>

The URL of the Commit

Implementations§

Source§

impl Commit

Source

pub fn check_for_circular_parents(&self) -> AtomicResult<()>

Throws an error if the parent is set to itself

Source

pub fn validate_previous_commit( &self, resource_old: &Resource, subject_url: &str, ) -> AtomicResult<()>

Source

pub fn validate_signature(&self, store: &impl Storelike) -> AtomicResult<()>

Check if the Commit’s signature matches the signer’s public key.

Source

pub fn validate_and_build_response( self, opts: &CommitOpts, store: &impl Storelike, ) -> AtomicResult<CommitResponse>

Performs the checks specified in CommitOpts and constructs a new Resource. Warning: Does not save the new resource to the Store - doet not delete if it destroy: true. Use Storelike::apply_commit to save the resource to the Store.

Source

pub fn validate_timestamp(&self) -> AtomicResult<()>

Checks if the Commit has been created in the future or if it is expired.

Source

pub fn apply_changes( &self, resource: Resource, store: &impl Storelike, ) -> AtomicResult<CommitApplied>

Updates the values in the Resource according to the set, remove, push, and destroy attributes in the Commit. Optionally also returns the updated Atoms.

Source

pub fn from_resource(resource: Resource) -> AtomicResult<Commit>

Converts a Resource of a Commit into a Commit

Source

pub fn into_resource(&self, store: &impl Storelike) -> AtomicResult<Resource>

Converts the Commit into a Resource with Atomic Values. Creates an identifier using the server_url Works for both Signed and Unsigned Commits

Source

pub fn get_subject(&self) -> &str

Source

pub fn serialize_deterministically_json_ad( &self, store: &impl Storelike, ) -> AtomicResult<String>

Generates a deterministic serialized JSON-AD representation of the Commit. Removes the signature from the object before serializing, since this function is used to check if the signature is correct.

Trait Implementations§

Source§

impl Clone for Commit

Source§

fn clone(&self) -> Commit

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Commit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Commit

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Commit

§

impl RefUnwindSafe for Commit

§

impl Send for Commit

§

impl Sync for Commit

§

impl Unpin for Commit

§

impl UnwindSafe for Commit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,