Skip to main content

Mapping

Struct Mapping 

Source
pub struct Mapping<T>
where T: AsRef<str>,
{ /* 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>
where T: AsRef<str>,

Source

pub fn endpoint(&self) -> &str

Path of the mapping.

It can be parametrized (e.g. /foo/%{path}/baz).

Source

pub fn mapping_type(&self) -> MappingType

Defines the type of the mapping.

This represent the data that will be published on the mapping.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn allow_unset(&self) -> Option<bool>

Allows the property to be unset.

Used only with properties.

Source

pub fn required(&self) -> Option<bool>

Marks the mapping as required.

Used only with object datastream.

Source

pub fn description(&self) -> Option<&T>

An optional description of the mapping.

Source

pub fn doc(&self) -> Option<&T>

A string containing documentation that will be injected in the generated client code.

Source

pub fn expiry_as_duration(&self) -> Result<Option<Duration>, SchemaError>

Expiry of the data stream.

If it’s None the stream will never expire.

Source

pub fn retention_with_expiry(&self) -> Result<InterfaceRetention, SchemaError>

Retention of the data stream.

See the Retention documentation for more information.

Source

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.

Source

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<T> Clone for Mapping<T>
where T: AsRef<str> + Clone,

Source§

fn clone(&self) -> Mapping<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Mapping<T>
where T: AsRef<str> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for Mapping<T>
where T: AsRef<str> + Deserialize<'de> + Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> From<&'a DatastreamIndividualMapping> for Mapping<Cow<'a, str>>

Source§

fn from(value: &'a DatastreamIndividualMapping) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a PropertiesMapping> for Mapping<Cow<'a, str>>

Source§

fn from(value: &'a PropertiesMapping) -> Self

Converts to this type from the input type.
Source§

impl<T> PartialEq for Mapping<T>
where T: AsRef<str> + PartialEq,

Source§

fn eq(&self, other: &Mapping<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Mapping<T>
where T: AsRef<str> + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> TryFrom<Mapping<T>> for DatastreamIndividualMapping
where T: AsRef<str> + Into<String>,

Source§

type Error = MappingError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Mapping<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Mapping<T>> for DatastreamObjectMapping
where T: AsRef<str> + Into<String>,

Source§

type Error = MappingError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Mapping<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Mapping<T>> for PropertiesMapping
where T: AsRef<str> + Into<String>,

Source§

type Error = MappingError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Mapping<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> Copy for Mapping<T>
where T: AsRef<str> + Copy,

Source§

impl<T> Eq for Mapping<T>
where T: AsRef<str> + Eq,

Source§

impl<T> StructuralPartialEq for Mapping<T>
where T: AsRef<str>,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,