pub struct CanReceiver<C: Clock, D> { /* private fields */ }
Expand description

Handles subscriptions and assembles incoming frames into transfers

Implementations§

source§

impl<C, D> CanReceiver<C, D>where C: Clock, D: ReceiveDriver<C>,

source

pub fn new(id: CanNodeId, mtu: Mtu) -> Self

Creates a receiver

id: The ID of this node. This is used to filter incoming service requests and responses.

source

pub fn new_anonymous(mtu: Mtu) -> Self

Creates an anonymous receiver

An anonymous receiver cannot receive service requests or responses.

source

pub fn set_id(&mut self, id: Option<CanNodeId>)

Updates the identifier of this node

This can be used after a node ID is identified to make this receiver capable of handling service transfers.

source

pub fn transfer_count(&self) -> u64

Returns the number of transfers successfully received

source

pub fn error_count(&self) -> u64

Returns the number of transfers that could not be received correctly

Errors include failure to allocate memory (when handling incoming frames only), missing frames, and malformed frames.

Trait Implementations§

source§

impl<C: Debug + Clock, D: Debug> Debug for CanReceiver<C, D>where C::Instant: Debug,

source§

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

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

impl<C, D> Receiver<C> for CanReceiver<C, D>where C: Clock, D: ReceiveDriver<C>,

source§

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.

source§

fn unsubscribe_message(&mut self, subject: SubjectId, driver: &mut Self::Driver)

Unsubscribes from messages on a subject

source§

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 memory allocation fails or if this node is anonymous.

source§

fn unsubscribe_request(&mut self, service: ServiceId, driver: &mut Self::Driver)

Unsubscribes from requests for a service

source§

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 memory allocation fails or if this node is anonymous.

source§

fn unsubscribe_response( &mut self, service: ServiceId, driver: &mut Self::Driver )

Unsubscribes from responses for a service

§

type Transport = CanTransport

The transport that this transmitter works with
§

type Driver = D

The driver type that this transmitter uses to receive frames
§

type Error = Error<<D as ReceiveDriver<C>>::Error>

An error type Read more
source§

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 Read more

Auto Trait Implementations§

§

impl<C, D> RefUnwindSafe for CanReceiver<C, D>where D: RefUnwindSafe, <<C as Clock>::Instant as Instant>::Duration: RefUnwindSafe, <C as Clock>::Instant: RefUnwindSafe,

§

impl<C, D> Send for CanReceiver<C, D>where D: Send, <<C as Clock>::Instant as Instant>::Duration: Send, <C as Clock>::Instant: Send,

§

impl<C, D> Sync for CanReceiver<C, D>where D: Sync, <<C as Clock>::Instant as Instant>::Duration: Sync, <C as Clock>::Instant: Sync,

§

impl<C, D> Unpin for CanReceiver<C, D>where D: Unpin, <<C as Clock>::Instant as Instant>::Duration: Unpin,

§

impl<C, D> UnwindSafe for CanReceiver<C, D>where D: UnwindSafe, <<C as Clock>::Instant as Instant>::Duration: UnwindSafe, <C as Clock>::Instant: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.