Skip to main content

ObjectSource

Trait ObjectSource 

Source
pub trait ObjectSource {
    // Required method
    fn object(&self, uuid: &str) -> Option<Box<dyn DynObject>>;

    // Provided methods
    fn read_object(&self, uuid: &str) -> Result<Box<dyn DynObject>, String> { ... }
    fn object_at(&self, uri: &str) -> Option<Box<dyn DynObject>> { ... }
    fn read_object_at(&self, uri: &str) -> Result<Box<dyn DynObject>, String> { ... }
    fn object_of(
        &self,
        reference: &(dyn Reflect + 'static),
    ) -> Option<Box<dyn DynObject>> { ... }
    fn read_object_of(
        &self,
        reference: &(dyn Reflect + 'static),
    ) -> Result<Box<dyn DynObject>, String> { ... }
}
Expand description

Resolving a uuid to an object.

The whole reason CRS reading is not a pure function: an eml 2.3 coordinate system is three data objects joined by references, so reading one means asking the store for the other two.

One trait, so everything above is written once. An EPC file implements it below; an ETP dataspace will implement it the same way and nothing else changes - which is the point of the seam, not a side effect.

Required Methods§

Source

fn object(&self, uuid: &str) -> Option<Box<dyn DynObject>>

An object of the store, by uuid. None when it holds no such object.

Provided Methods§

Source

fn read_object(&self, uuid: &str) -> Result<Box<dyn DynObject>, String>

The same, saying why when there is nothing to hand back.

A reader resolving a reference does not care why the target is absent - it has one thing to do either way. A reader walking a whole package does: this part breaks its schema and this package holds no such object are repaired in different places, and the first is the message that names the switch (--lenient, --strict) which would help.

Provided rather than required, so a source with nothing more to say implements nothing; the ones that know the reason override it.

Source

fn object_at(&self, uri: &str) -> Option<Box<dyn DynObject>>

An object by its uri - the address a caller holds when it has one.

Two versions of an object share a uuid, and only the uri tells them apart (ADR-0003, ADR-0010): a store that can hold both overrides this with its own resolution, and answers the version the uri names or refuses by name. The default is for a source that holds one object per uuid - for it the uuid is the address, so it is asked by the uuid the uri carries.

Source

fn read_object_at(&self, uri: &str) -> Result<Box<dyn DynObject>, String>

ObjectSource::object_at, saying why when there is nothing.

Source

fn object_of( &self, reference: &(dyn Reflect + 'static), ) -> Option<Box<dyn DynObject>>

The object a reference names - a DataObjectReference, a ContactElementReference, a ContactElement - by its full identity (energyml_core::identity::address_of_reflect): the version it names is the version read, and a reference that names no type is followed by its uuid, the only address it has. The one way a reader follows a reference.

Source

fn read_object_of( &self, reference: &(dyn Reflect + 'static), ) -> Result<Box<dyn DynObject>, String>

ObjectSource::object_of, saying why when there is nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ObjectSource for EpcStore

Source§

fn object(&self, uuid: &str) -> Option<Box<dyn DynObject>>

Source§

fn read_object(&self, uuid: &str) -> Result<Box<dyn DynObject>, String>

Source§

fn object_at(&self, uri: &str) -> Option<Box<dyn DynObject>>

Source§

fn read_object_at(&self, uri: &str) -> Result<Box<dyn DynObject>, String>

Implementors§