pub trait UTransport: Send + Sync {
// Required method
fn send<'life0, 'async_trait>(
&'life0 self,
message: UMessage,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn receive<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
) -> Pin<Box<dyn Future<Output = Result<UMessage, UStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn register_listener<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
_listener: Arc<dyn UListener>,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn unregister_listener<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
_listener: Arc<dyn UListener>,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}
Expand description
The uProtocol Transport Layer interface that provides a common API for uEntity developers to send and receive messages.
Implementations contain the details for connecting to the underlying transport technology and
sending UMessage
s using the configured technology.
Please refer to the uProtocol Transport Layer specification for details.
Required Methods§
Sourcefn send<'life0, 'async_trait>(
&'life0 self,
message: UMessage,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
message: UMessage,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a message using this transport’s message exchange mechanism.
§Arguments
message
- The message to send. Thetype
,source
andsink
properties of the UAttributes contained in the message determine the addressing semantics.
§Errors
Returns an error if the message could not be sent.
Provided Methods§
Sourcefn receive<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
) -> Pin<Box<dyn Future<Output = Result<UMessage, UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn receive<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
) -> Pin<Box<dyn Future<Output = Result<UMessage, UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Receives a message from the transport.
This default implementation returns an error with UCode::UNIMPLEMENTED
.
§Arguments
source_filter
- The source address pattern that the message to receive needs to match.sink_filter
- The sink address pattern that the message to receive needs to match, orNone
to indicate that the message must not contain any sink address.
§Errors
Returns an error if no message could be received, e.g. because no message matches the given addresses.
Sourcefn register_listener<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
_listener: Arc<dyn UListener>,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn register_listener<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
_listener: Arc<dyn UListener>,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Registers a listener to be called for messages.
The listener will be invoked for each message that matches the given source and sink filter patterns according to the rules defined by the UUri specification.
This default implementation returns an error with UCode::UNIMPLEMENTED
.
§Arguments
source_filter
- The source address pattern that messages need to match.sink_filter
- The sink address pattern that messages need to match, orNone
to match messages that do not contain any sink address.listener
- The listener to invoke. The listener can be unregistered again usingUTransport::unregister_listener
.
§Errors
Returns an error if the listener could not be registered.
Sourcefn unregister_listener<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
_listener: Arc<dyn UListener>,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn unregister_listener<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_source_filter: &'life1 UUri,
_sink_filter: Option<&'life2 UUri>,
_listener: Arc<dyn UListener>,
) -> Pin<Box<dyn Future<Output = Result<(), UStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Deregisters a message listener.
The listener will no longer be called for any (matching) messages after this function has returned successfully.
This default implementation returns an error with UCode::UNIMPLEMENTED
.
§Arguments
source_filter
- The source address pattern that the listener had been registered for.sink_filter
- The sink address pattern that the listener had been registered for.listener
- The listener to unregister.
§Errors
Returns an error if the listener could not be unregistered, for example if the given listener does not exist.
Implementors§
impl UTransport for LocalTransport
impl UTransport for MockTransport
This delegates the invocation of the UTransport functions to the mocked functions of the Transport struct. see https://github.com/asomers/mockall/issues/571