[][src]Struct atomic_lib::resources::Resource

pub struct Resource<'a> { /* fields omitted */ }

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 calling .save().

Implementations

impl<'a> Resource<'a>[src]

pub fn get_classes(&mut self) -> AtomicResult<Vec<Class>>[src]

Checks if the classes are there, if not, fetches them

pub fn new(subject: String, store: &'a dyn Storelike) -> Resource<'a>[src]

Create a new, empty Resource.

pub fn new_instance(
    class_url: &str,
    store: &'a dyn Storelike
) -> AtomicResult<Resource<'a>>
[src]

Create a new instance of some Class. The subject is generated, but can be changed.

pub fn new_from_resource_string(
    subject: String,
    resource_string: &ResourceString,
    store: &'a dyn Storelike
) -> AtomicResult<Resource<'a>>
[src]

pub fn get(&self, property_url: &str) -> AtomicResult<&Value>[src]

Get a value by property URL

pub fn get_propvals(&self) -> PropVals[src]

pub fn get_shortname(&self, shortname: &str) -> AtomicResult<Value>[src]

Gets a value by its shortname

pub fn remove_propval(&mut self, property_url: &str)[src]

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

pub fn resolve_shortname_to_property(
    &mut self,
    shortname: &str
) -> AtomicResult<Option<Property>>
[src]

Tries to resolve the shortname of a Property to a Property URL.

pub fn save(&self) -> AtomicResult<()>[src]

Saves the resource (with all the changes) to the store Should be run after any (batch of) changes to the Resource!

pub fn set_propval_string(
    &mut self,
    property_url: String,
    value: &str
) -> AtomicResult<()>
[src]

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

pub fn set_propval(
    &mut self,
    property: String,
    value: Value
) -> AtomicResult<()>
[src]

Inserts a Property/Value combination. Overwrites existing. Does not validate property / datatype combination

pub fn set_by_shortname(
    &mut self,
    property: &str,
    value: &str
) -> AtomicResult<()>
[src]

Sets a property / value combination. Property can be a shortname (e.g. 'description' instead of the full URL), if the Resource has a Class. Validates the datatype.

pub fn set_subject(&mut self, url: String)[src]

pub fn get_subject(&self) -> &String[src]

pub fn to_plain(&self) -> HashMap<String, String>[src]

Converts a resource to a string only HashMap

pub fn to_ad3(&self) -> AtomicResult<String> where
    Self: Sized
[src]

Serializes Resource to Atomic Data Triples (ad3), and NDJSON serialized representation.

pub fn to_json(
    &self,
    store: &dyn Storelike,
    _depth: u8,
    json_ld: bool
) -> AtomicResult<String> where
    Self: Sized
[src]

Serializes a single Resource to a JSON object. It uses the Shortnames of properties for Keys. The depth is useful, since atomic data allows for cyclical (infinite-depth) relationships

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Resource<'a>

impl<'a> !Send for Resource<'a>

impl<'a> !Sync for Resource<'a>

impl<'a> Unpin for Resource<'a>

impl<'a> !UnwindSafe for Resource<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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