Preview of the proposed up-rust native-frame-model branch (up-rust b6b99c6d, up-spec f0e9b17) — not released documentation. branch · write-up

Trait USubscription

Source
pub trait USubscription: Send + Sync {
    // Required methods
    fn subscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 UUri,
        expiration: Option<u64>,
        min_sample_period: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = Result<SubscriptionStatus, UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn unsubscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 UUri,
    ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_subscriptions_by_topic<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 UUri,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SubscriptionInfo>, UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_subscriptions_by_subscriber<'life0, 'life1, 'async_trait>(
        &'life0 self,
        subscriber: &'life1 UUri,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SubscriptionInfo>, UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn register_for_notifications<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 UUri,
    ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn unregister_for_notifications<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 UUri,
    ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_subscribers<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 UUri,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<UUri>, UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn reset<'life0, 'async_trait>(
        &'life0 self,
        reason: ResetReason,
        message: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The uProtocol Application Layer client interface to the uSubscription service.

Please refer to the uSubscription service specification for details.

Note that in contrast to the uSubscription service specification, the functions defined in this trait only support commonly used input and output parameters of the operations defined in the specification. This is mainly due to the fact, that for many of the other parameters defined in the specification, it is not entirely clear if and how they should be used in practice. The next version of the uSubscription service specification will include a more detailed description of the operations and their parameters, which will then be reflected in the next version of this trait.

Required Methods§

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 UUri, expiration: Option<u64>, min_sample_period: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<SubscriptionStatus, UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribes to a topic.

§Parameters
  • topic - The topic to subscribe to.
  • expiration - The point in time at which the subscription expires (milliseconds since Unix epoch). If not specified, the subscription is valid until explicitly unsubscribed.
  • min_sample_period - The minimum duration (in seconds) between two events that should be maintained for remote only topics. Device dispatchers use this attribute to reduce the publication rates of events sent between devices. This attribute is commonly used for mobile/cloud components subscribing to vehicle topics that are published at a high rate. If the desired sampling period set by the subscriber is lower than the original publisher’s publication period, the attribute is ignored. If not specified, the sampling period is set by the publisher.
§Returns

The outcome of the attempt to establish the subscription.

Source

fn unsubscribe<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 UUri, ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unsubscribes this client from a topic.

§Parameters
  • topic - The topic to unsubscribe from.
§Errors

Returns an error if the attempt to unsubscribe has failed.

Source

fn fetch_subscriptions_by_topic<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 UUri, ) -> Pin<Box<dyn Future<Output = Result<Vec<SubscriptionInfo>, UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets all (currently) active subscriptions for a given topic.

§Parameters
  • topic - The topic to fetch subscriptions for.
§Errors

Returns an error if the attempt to retrieve the subscriptions has failed.

Source

fn fetch_subscriptions_by_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, subscriber: &'life1 UUri, ) -> Pin<Box<dyn Future<Output = Result<Vec<SubscriptionInfo>, UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets a uEntity’s (currently) active subscriptions.

§Parameters
  • subscriber - The uEntity to get the subscriptions for.
§Errors

Returns an error if the attempt to retrieve the subscriptions has failed.

Source

fn register_for_notifications<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 UUri, ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Registers this client for notifications about changes to the subscription status for a given topic.

§Parameters
  • topic - The topic to receive changes to subscription status for.
§Errors

Returns an error if the attempt to register for notifications has failed.

Source

fn unregister_for_notifications<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 UUri, ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unregisters this client from notifications about changes to the subscription status for a given topic.

§Parameters
  • topic - The topic to no longer receive changes to subscription status for.
§Errors

Returns an error if the attempt to unregister from notifications has failed.

Source

fn fetch_subscribers<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 UUri, ) -> Pin<Box<dyn Future<Output = Result<Vec<UUri>, UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches a list of subscribers that are currently subscribed to a given topic.

§Parameters
  • topic - The topic to fetch subscriptions for.
§Returns

A list of URIs representing the uEntities that are subscribed to the given topic.

§Errors

Returns an error if the attempt to fetch subscribers has failed.

Source

fn reset<'life0, 'async_trait>( &'life0 self, reason: ResetReason, message: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Flushes all stored subscription information, including any persistently stored subscriptions.

§Parameters
  • reason - The reason for the reset.
  • message - An optional human-readable message providing additional context about the reset.
§Errors

Returns an error if the attempt to reset has failed.

Implementors§