Trait canadensis_core::transport::Receiver
source · pub trait Receiver<C>where
C: Clock,{
type Transport: Transport;
type Driver;
type Error: Debug + From<OutOfMemoryError>;
// Required methods
fn receive(
&mut self,
clock: &mut C,
driver: &mut Self::Driver
) -> Result<Option<Transfer<Vec<u8>, C::Instant, Self::Transport>>, Self::Error>;
fn subscribe_message(
&mut self,
subject: SubjectId,
payload_size_max: usize,
timeout: <<C as Clock>::Instant as Instant>::Duration,
driver: &mut Self::Driver
) -> Result<(), Self::Error>;
fn unsubscribe_message(
&mut self,
subject: SubjectId,
driver: &mut Self::Driver
);
fn subscribe_request(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <<C as Clock>::Instant as Instant>::Duration,
driver: &mut Self::Driver
) -> Result<(), ServiceSubscribeError<Self::Error>>;
fn unsubscribe_request(
&mut self,
service: ServiceId,
driver: &mut Self::Driver
);
fn subscribe_response(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <<C as Clock>::Instant as Instant>::Duration,
driver: &mut Self::Driver
) -> Result<(), ServiceSubscribeError<Self::Error>>;
fn unsubscribe_response(
&mut self,
service: ServiceId,
driver: &mut Self::Driver
);
}
Expand description
A receiver that can assemble incoming frames into transfers
Required Associated Types§
sourcetype Error: Debug + From<OutOfMemoryError>
type Error: Debug + From<OutOfMemoryError>
An error type
This type must have an out-of-memory variant that can hold an OutOfMemoryError
.
Required Methods§
sourcefn receive(
&mut self,
clock: &mut C,
driver: &mut Self::Driver
) -> Result<Option<Transfer<Vec<u8>, C::Instant, Self::Transport>>, Self::Error>
fn receive( &mut self, clock: &mut C, driver: &mut Self::Driver ) -> Result<Option<Transfer<Vec<u8>, C::Instant, Self::Transport>>, Self::Error>
Checks for incoming frames and processes them, possibly returning a transfer
If the frame completes a transfer and the transfer matches an active subscription, the transfer is returned.
This function must not block. If no frame can immediately be read, it should return Ok(None)
.
If the transport reads a frame and processes it, but the frame does not complete a transfer,
this function must try again to read and process a frame. It must not return Ok(None)
if there are incoming frames that remain to be processed.
This function must not return any transfers for which the transport is not currently subscribed. It also must not return any service transfers not addressed to this node.
The argument now
should be the current time. This may be used to assign timestamps to
incoming frames and delete sessions that have timed out.
sourcefn subscribe_message(
&mut self,
subject: SubjectId,
payload_size_max: usize,
timeout: <<C as Clock>::Instant as Instant>::Duration,
driver: &mut Self::Driver
) -> Result<(), Self::Error>
fn subscribe_message( &mut self, subject: SubjectId, payload_size_max: usize, timeout: <<C as Clock>::Instant as Instant>::Duration, driver: &mut Self::Driver ) -> Result<(), Self::Error>
Subscribes to messages on a subject
This will enable incoming transfers from all nodes on the specified subject ID.
subject: The subject ID to subscribe to
payload_size_max: The maximum number of payload bytes expected on this subject (longer transfers will be dropped)
timeout: The maximum time between the first and last frames in a transfer (transfers that do not finish within this time will be dropped)
If all transfers fit into one frame, the timeout has no meaning and may be zero.
sourcefn unsubscribe_message(&mut self, subject: SubjectId, driver: &mut Self::Driver)
fn unsubscribe_message(&mut self, subject: SubjectId, driver: &mut Self::Driver)
Unsubscribes from messages on a subject
sourcefn subscribe_request(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <<C as Clock>::Instant as Instant>::Duration,
driver: &mut Self::Driver
) -> Result<(), ServiceSubscribeError<Self::Error>>
fn subscribe_request( &mut self, service: ServiceId, payload_size_max: usize, timeout: <<C as Clock>::Instant as Instant>::Duration, driver: &mut Self::Driver ) -> Result<(), ServiceSubscribeError<Self::Error>>
Subscribes to requests for a service
This will enable incoming service request transfers from all nodes on the specified service ID.
service: The service ID to subscribe to
payload_size_max: The maximum number of payload bytes expected on this subject (longer transfers will be dropped)
timeout: The maximum time between the first and last frames in a transfer (transfers that do not finish within this time will be dropped)
If all transfers fit into one frame, the timeout has no meaning and may be zero.
This function returns an error if this node is anonymous or some other transport error occurs.
sourcefn unsubscribe_request(&mut self, service: ServiceId, driver: &mut Self::Driver)
fn unsubscribe_request(&mut self, service: ServiceId, driver: &mut Self::Driver)
Unsubscribes from requests for a service
sourcefn subscribe_response(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <<C as Clock>::Instant as Instant>::Duration,
driver: &mut Self::Driver
) -> Result<(), ServiceSubscribeError<Self::Error>>
fn subscribe_response( &mut self, service: ServiceId, payload_size_max: usize, timeout: <<C as Clock>::Instant as Instant>::Duration, driver: &mut Self::Driver ) -> Result<(), ServiceSubscribeError<Self::Error>>
Subscribes to responses for a service
This will enable incoming service response transfers from all nodes on the specified service ID.
service: The service ID to subscribe to
payload_size_max: The maximum number of payload bytes expected on this subject (longer transfers will be dropped)
timeout: The maximum time between the first and last frames in a transfer (transfers that do not finish within this time will be dropped)
If all transfers fit into one frame, the timeout has no meaning and may be zero.
This function returns an error if this node is anonymous or some other transport error occurs.
sourcefn unsubscribe_response(
&mut self,
service: ServiceId,
driver: &mut Self::Driver
)
fn unsubscribe_response( &mut self, service: ServiceId, driver: &mut Self::Driver )
Unsubscribes from responses for a service