pub struct Resource { /* private fields */ }
Expand description

A Resource is a set of Atoms that shares a single Subject. A Resource only contains valid Values, but it might lack required properties. All changes to the Resource are applied after committing them (e.g. by using).

Implementations

Fetches all ‘required’ properties. Returns an error if any are missing in this Resource.

Removes / deletes the resource from the store by performing a Commit.

Get a value by property URL

Checks if the classes are there, if not, fetches them. Returns an empty vector if there are no classes found.

Returns the first item of the is_ array

Returns the Parent of this Resource. Throws in case of recursion

Walks the parent tree upwards until there is no parent, then returns them as a vector.

Returns all PropVals. Useful if you want to iterate over all Atoms / Properties.

Gets a value by its property shortname or property URL.

checks if a resouce has a specific parent. iterates over all parents.

Returns all PropVals.

Create a new, empty Resource.

Create a new resource with a generated Subject

Create a new instance of some Class. The subject is generated, but can be changed. Does not save the resource to the store.

Appends a Resource to a specific property through the commitbuilder. Useful if you want to have compact Commits that add things to existing ResourceArrays.

Remove a propval from a resource by property URL.

Remove a propval from a resource by property URL or shortname. Returns error if propval does not exist in this resource or its class.

Tries to resolve the shortname of a Property to a Property. Currently only tries the shortnames for linked classes - not for other properties.

Saves the resource (with all the changes) to the store by creating a Commit. Uses default Agent to sign the Commit. Stores changes on the Subject’s Server by sending a Commit. Returns the generated Commit, the new Resource and the old Resource.

Saves the resource (with all the changes) to the store by creating a Commit. Uses default Agent to sign the Commit. Returns the generated Commit and the new Resource. Does not validate rights / hierarchy. Does not store these changes on the server of the Subject - the Commit will be lost, unless you handle it manually.

Overwrites the is_a (Class) of the Resource.

Insert a Property/Value combination. Overwrites existing Property/Value. Validates the datatype.

Inserts a Property/Value combination. Checks datatype. Overwrites existing. Adds the change to the commit builder’s set map.

Does not validate property / datatype combination. Inserts a Property/Value combination. Overwrites existing. Adds it to the CommitBuilder.

Sets a property / value combination. Property can be a shortname (e.g. ‘description’ instead of the full URL). Returns error if propval does not exist in this resource or its class.

Overwrites all current PropVals. Does not perform validation.

Changes the subject of the Resource. Does not ‘move’ the Resource See https://github.com/atomicdata-dev/atomic-data-rust/issues/44

Converts Resource to JSON-AD string.

Converts Resource to plain JSON string.

Converts Resource to JSON-LD string, with @context object and RDF compatibility.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more