pub struct Mapping<T>{ /* private fields */ }Expand description
Mapping of an Interface.
It includes all the fields available for a mapping, but it it is validated when built with the
TryFrom. It uniforms the different types of mappings like
DatastreamIndividualMapping,
DatastreamObjectMapping
mappings and PropertiesMapping in a single
struct.
Since it’s a 1:1 representation of the JSON it is used for serialization and deserialization,
and then is converted to the internal representation of the mapping with the TryFrom and
From traits of the Interface’s mappings.
You can find the specification here Mapping Schema -
Astarte
Implementations§
Source§impl<T> Mapping<T>
impl<T> Mapping<T>
Sourcepub fn endpoint(&self) -> &str
pub fn endpoint(&self) -> &str
Path of the mapping.
It can be parametrized (e.g. /foo/%{path}/baz).
Sourcepub fn mapping_type(&self) -> MappingType
pub fn mapping_type(&self) -> MappingType
Defines the type of the mapping.
This represent the data that will be published on the mapping.
Sourcepub fn reliability(&self) -> Option<Reliability>
pub fn reliability(&self) -> Option<Reliability>
Defines when to consider the data delivered.
Useful only with datastream. Defines whether the sent data should be considered delivered when the transport successfully sends the data (unreliable), when we know that the data has been received at least once (guaranteed) or when we know that the data has been received exactly once (unique). Unreliable by default. When using reliable data, consider you might incur in additional resource usage on both the transport and the device’s end.
Sourcepub fn explicit_timestamp(&self) -> Option<bool>
pub fn explicit_timestamp(&self) -> Option<bool>
Allow to set a custom timestamp.
Otherwise a timestamp is added when the message is received. If true explicit timestamp will also be used for sorting. This feature is only supported on datastreams.
Sourcepub fn retention(&self) -> Option<Retention>
pub fn retention(&self) -> Option<Retention>
Retention of the data when not deliverable.
Useful only with datastream. Defines whether the sent data should be discarded if the transport is temporarily uncapable of delivering it (discard) or should be kept in a cache in memory (volatile) or on disk (stored), and guaranteed to be delivered in the timeframe defined by the expiry.
Sourcepub fn expiry(&self) -> Option<i64>
pub fn expiry(&self) -> Option<i64>
Expiry for the retain data.
Useful when retention is stored. Defines after how many seconds a specific data entry should be kept before giving up and erasing it from the persistent cache. A value <= 0 means the persistent cache never expires, and is the default.
Sourcepub fn database_retention_policy(&self) -> Option<DatabaseRetentionPolicy>
pub fn database_retention_policy(&self) -> Option<DatabaseRetentionPolicy>
Retention policy for the database.
Useful only with datastream. Defines whether data should expire from the database after a
given interval. Valid values are: no_ttl and use_ttl.
Sourcepub fn database_retention_ttl(&self) -> Option<i64>
pub fn database_retention_ttl(&self) -> Option<i64>
Seconds to keep the data in the database.
Useful when database_retention_policy is “use_ttl”. Defines how many seconds a specific data
entry should be kept before erasing it from the database.
Sourcepub fn allow_unset(&self) -> Option<bool>
pub fn allow_unset(&self) -> Option<bool>
Allows the property to be unset.
Used only with properties.
Sourcepub fn required(&self) -> Option<bool>
pub fn required(&self) -> Option<bool>
Marks the mapping as required.
Used only with object datastream.
Sourcepub fn description(&self) -> Option<&T>
pub fn description(&self) -> Option<&T>
An optional description of the mapping.
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 expiry_as_duration(&self) -> Result<Option<Duration>, SchemaError>
pub fn expiry_as_duration(&self) -> Result<Option<Duration>, SchemaError>
Expiry of the data stream.
If it’s None the stream will never expire.
Sourcepub fn retention_with_expiry(&self) -> Result<InterfaceRetention, SchemaError>
pub fn retention_with_expiry(&self) -> Result<InterfaceRetention, SchemaError>
Retention of the data stream.
See the Retention documentation for more information.
Sourcepub fn database_retention_ttl_as_duration(
&self,
) -> Result<Option<Duration>, SchemaError>
pub fn database_retention_ttl_as_duration( &self, ) -> Result<Option<Duration>, SchemaError>
Database retention ttl of the data stream.
If it’s None the stream will never expire.
Sourcepub fn database_retention_with_ttl(
&self,
) -> Result<InterfaceDatabaseRetention, SchemaError>
pub fn database_retention_with_ttl( &self, ) -> Result<InterfaceDatabaseRetention, SchemaError>
Returns the database retention of the data stream.
See the DatabaseRetention for more information.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Mapping<T>
impl<'de, T> Deserialize<'de> for Mapping<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<'a> From<&'a DatastreamIndividualMapping> for Mapping<Cow<'a, str>>
impl<'a> From<&'a DatastreamIndividualMapping> for Mapping<Cow<'a, str>>
Source§fn from(value: &'a DatastreamIndividualMapping) -> Self
fn from(value: &'a DatastreamIndividualMapping) -> Self
Source§impl<'a> From<&'a PropertiesMapping> for Mapping<Cow<'a, str>>
impl<'a> From<&'a PropertiesMapping> for Mapping<Cow<'a, str>>
Source§fn from(value: &'a PropertiesMapping) -> Self
fn from(value: &'a PropertiesMapping) -> Self
Source§impl<T> PartialEq for Mapping<T>
impl<T> PartialEq for Mapping<T>
Source§impl<T> TryFrom<Mapping<T>> for DatastreamIndividualMapping
impl<T> TryFrom<Mapping<T>> for DatastreamIndividualMapping
Source§impl<T> TryFrom<Mapping<T>> for DatastreamObjectMapping
impl<T> TryFrom<Mapping<T>> for DatastreamObjectMapping
Source§impl<T> TryFrom<Mapping<T>> for PropertiesMapping
impl<T> TryFrom<Mapping<T>> for PropertiesMapping
impl<T> Copy for Mapping<T>
impl<T> Eq for Mapping<T>
impl<T> StructuralPartialEq for Mapping<T>
Auto Trait Implementations§
impl<T> Freeze for Mapping<T>where
T: Freeze,
impl<T> RefUnwindSafe for Mapping<T>where
T: RefUnwindSafe,
impl<T> Send for Mapping<T>where
T: Send,
impl<T> Sync for Mapping<T>where
T: Sync,
impl<T> Unpin for Mapping<T>where
T: Unpin,
impl<T> UnsafeUnpin for Mapping<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Mapping<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.