pub struct InterfaceJson<T>{ /* private fields */ }Expand description
The structure is a direct mapping of the JSON schema, they are then transformed in our
internal representation of Interface when de-serializing using
TryFrom.
The fields of the JSON can either be:
- Required: the field is the value it represents, it cannot be omitted.
- Optional with default: the field is optional, but it is value it represents (not wrapped
in
Option). It will not be serialized if the value is the default one. - Optional: the field is optional, it is wrapped in
Option. It will not be serialized if the value isNone.
Implementations§
Source§impl<T> InterfaceJson<T>
impl<T> InterfaceJson<T>
Sourcepub fn interface_name(&self) -> &str
pub fn interface_name(&self) -> &str
The name of the interface.
This has to be an unique, alphanumeric reverse internet domain name, shorter than 128 characters.
Sourcepub fn version_major(&self) -> i32
pub fn version_major(&self) -> i32
The Major version qualifier for this interface.
Interfaces with the same id and different version_major number are deemed incompatible. It
is then acceptable to redefine any property of the interface when changing the major
version number.
It must be a positive number.
Sourcepub fn version_minor(&self) -> i32
pub fn version_minor(&self) -> i32
The Minor version qualifier for this interface.
Interfaces with the same id and major version number and different version_minor number are
deemed compatible between each other. When changing the minor number, it is then only
possible to insert further mappings. Any other modification might lead to
incompatibilities and undefined behavior.
It must be a positive number.
Sourcepub fn interface_type(&self) -> InterfaceType
pub fn interface_type(&self) -> InterfaceType
Identifies the type of this Interface.
Currently two types are supported: datastream and properties. Datastream should be used when dealing with streams of non-persistent data, where a single path receives updates and there’s no concept of state. Properties, instead, are meant to be an actual state and as such they have only a change history, and are retained.
Sourcepub fn ownership(&self) -> Ownership
pub fn ownership(&self) -> Ownership
Identifies the direction of the interface.
Interfaces are meant to be unidirectional, and this property defines who’s sending or receiving data. device means the device/gateway is sending data to Astarte, consumer means the device/gateway is receiving data from Astarte. Bidirectional mode is not supported, you should instantiate another interface for that.
Sourcepub fn aggregation(&self) -> Option<Aggregation>
pub fn aggregation(&self) -> Option<Aggregation>
Identifies the aggregation of the mappings of the interface.
Individual means every mapping changes state or streams data independently, whereas an object aggregation treats the interface as an object, making all the mappings changes interdependent. Choosing the right aggregation might drastically improve performances.
Sourcepub fn description(&self) -> Option<&T>
pub fn description(&self) -> Option<&T>
An optional description of the interface.
Sourcepub fn doc(&self) -> Option<&T>
pub fn doc(&self) -> Option<&T>
A string containing documentation that will be injected in the generated client code.
Sourcepub fn mappings(&self) -> &[Mapping<T>]
pub fn mappings(&self) -> &[Mapping<T>]
Mappings define the endpoint of the interface, where actual data is stored/streamed.
They are defined as relative URLs (e.g. /my/path) and can be parametrized (e.g.: /%{myparam}/path). A valid interface must have no mappings clash, which means that every mapping must resolve to a unique path or collection of paths (including parametrization). Every mapping acquires type, quality and aggregation of the interface.
Trait Implementations§
Source§impl<T> Clone for InterfaceJson<T>
impl<T> Clone for InterfaceJson<T>
Source§fn clone(&self) -> InterfaceJson<T>
fn clone(&self) -> InterfaceJson<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for InterfaceJson<T>
impl<T> Debug for InterfaceJson<T>
Source§impl<'de, T> Deserialize<'de> for InterfaceJson<T>
impl<'de, T> Deserialize<'de> for InterfaceJson<T>
Source§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>,
Source§impl<T> PartialEq for InterfaceJson<T>
impl<T> PartialEq for InterfaceJson<T>
Source§fn eq(&self, other: &InterfaceJson<T>) -> bool
fn eq(&self, other: &InterfaceJson<T>) -> bool
self and other values to be equal, and is used by ==.Source§impl<T> Serialize for InterfaceJson<T>
impl<T> Serialize for InterfaceJson<T>
Source§impl<T> TryFrom<InterfaceJson<T>> for DatastreamIndividual
impl<T> TryFrom<InterfaceJson<T>> for DatastreamIndividual
Source§impl<T> TryFrom<InterfaceJson<T>> for DatastreamObject
impl<T> TryFrom<InterfaceJson<T>> for DatastreamObject
Source§impl<T> TryFrom<InterfaceJson<T>> for Interface
impl<T> TryFrom<InterfaceJson<T>> for Interface
Source§impl<T> TryFrom<InterfaceJson<T>> for Properties
impl<T> TryFrom<InterfaceJson<T>> for Properties
impl<T> Eq for InterfaceJson<T>
impl<T> StructuralPartialEq for InterfaceJson<T>
Auto Trait Implementations§
impl<T> Freeze for InterfaceJson<T>where
T: Freeze,
impl<T> RefUnwindSafe for InterfaceJson<T>where
T: RefUnwindSafe,
impl<T> Send for InterfaceJson<T>where
T: Send,
impl<T> Sync for InterfaceJson<T>where
T: Sync,
impl<T> Unpin for InterfaceJson<T>where
T: Unpin,
impl<T> UnsafeUnpin for InterfaceJson<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for InterfaceJson<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.