Struct canadensis_can::CanReceiver
source · 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>,
impl<C, D> CanReceiver<C, D>where C: Clock, D: ReceiveDriver<C>,
sourcepub fn new(id: CanNodeId, mtu: Mtu) -> Self
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.
sourcepub fn new_anonymous(mtu: Mtu) -> Self
pub fn new_anonymous(mtu: Mtu) -> Self
Creates an anonymous receiver
An anonymous receiver cannot receive service requests or responses.
sourcepub fn set_id(&mut self, id: Option<CanNodeId>)
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.
sourcepub fn transfer_count(&self) -> u64
pub fn transfer_count(&self) -> u64
Returns the number of transfers successfully received
sourcepub fn error_count(&self) -> u64
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, D> Receiver<C> for CanReceiver<C, D>where
C: Clock,
D: ReceiveDriver<C>,
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>
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)
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>>
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)
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>>
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
)
fn unsubscribe_response( &mut self, service: ServiceId, driver: &mut Self::Driver )
Unsubscribes from responses for a service