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
impl Commit
Sourcepub fn check_for_circular_parents(&self) -> AtomicResult<()>
pub fn check_for_circular_parents(&self) -> AtomicResult<()>
Throws an error if the parent is set to itself
pub fn validate_previous_commit( &self, resource_old: &Resource, subject_url: &str, ) -> AtomicResult<()>
Sourcepub fn validate_signature(&self, store: &impl Storelike) -> AtomicResult<()>
pub fn validate_signature(&self, store: &impl Storelike) -> AtomicResult<()>
Check if the Commit’s signature matches the signer’s public key.
Sourcepub fn validate_and_build_response(
self,
opts: &CommitOpts,
store: &impl Storelike,
) -> AtomicResult<CommitResponse>
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.
Sourcepub fn validate_timestamp(&self) -> AtomicResult<()>
pub fn validate_timestamp(&self) -> AtomicResult<()>
Checks if the Commit has been created in the future or if it is expired.
Sourcepub fn apply_changes(
&self,
resource: Resource,
store: &impl Storelike,
) -> AtomicResult<CommitApplied>
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.
Sourcepub fn from_resource(resource: Resource) -> AtomicResult<Commit>
pub fn from_resource(resource: Resource) -> AtomicResult<Commit>
Converts a Resource of a Commit into a Commit
Sourcepub fn into_resource(&self, store: &impl Storelike) -> AtomicResult<Resource>
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
pub fn get_subject(&self) -> &str
Sourcepub fn serialize_deterministically_json_ad(
&self,
store: &impl Storelike,
) -> AtomicResult<String>
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.