Struct atomic_lib::resources::Resource [−][src]
pub struct Resource { /* fields omitted */ }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. Fails is 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 all PropVals. Useful if you want to iterate over all Atoms / Properties.
Gets a value by its property shortname or property URL.
Create a new instance of some Class. The subject is generated, but can be changed. Does not save the resource to the store.
Remove a propval from a resource by property URL.
pub fn remove_propval_shortname(
&mut self,
property_shortname: &str,
store: &impl Storelike
) -> AtomicResult<()>
pub fn remove_propval_shortname(
&mut self,
property_shortname: &str,
store: &impl Storelike
) -> AtomicResult<()>
Remove a propval from a resource by property URL or shortname. Returns error if propval does not exist in this resource or its class.
pub fn resolve_shortname_to_property(
&self,
shortname: &str,
store: &impl Storelike
) -> AtomicResult<Property>
pub fn resolve_shortname_to_property(
&self,
shortname: &str,
store: &impl Storelike
) -> AtomicResult<Property>
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.
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. 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.
pub fn set_propval_string(
&mut self,
property_url: String,
value: &str,
store: &impl Storelike
) -> AtomicResult<()>
pub fn set_propval_string(
&mut self,
property_url: String,
value: &str,
store: &impl Storelike
) -> AtomicResult<()>
Insert a Property/Value combination. Overwrites existing Property/Value. Validates the datatype.
pub fn set_propval(
&mut self,
property: String,
value: Value,
store: &impl Storelike
) -> AtomicResult<()>
pub fn set_propval(
&mut self,
property: String,
value: Value,
store: &impl Storelike
) -> AtomicResult<()>
Inserts a Property/Value combination. Overwrites existing. Adds it to the commit builder.
Does not validate property / datatype combination. Inserts a Property/Value combination. Overwrites existing. Adds it to the CommitBuilder.
pub fn set_propval_shortname(
&mut self,
property: &str,
value: &str,
store: &impl Storelike
) -> AtomicResult<()>
pub fn set_propval_shortname(
&mut self,
property: &str,
value: &str,
store: &impl Storelike
) -> AtomicResult<()>
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.
Changes the subject of the Resource. Does not ‘move’ the Resource See https://github.com/joepio/atomic/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
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Resource
impl UnwindSafe for Resource
Blanket Implementations
Mutably borrows from an owned value. Read more