Struct canadensis::node::CoreNode
source · pub struct CoreNode<C, T, U, TR, D, const P: usize, const R: usize>where
C: Clock,
U: Receiver<C>,
T: Transmitter<C>,{ /* private fields */ }
Expand description
Basic Cyphal node functionality
Type parameters:
C
: The clock used to get the current timeT
: The transmitter used to send transfersU
: The receiver used to receive transfersTR
: The transfer ID tracker used to manage transfer IDs for outgoing transfersD
: The driver used to send and receive framesP
: The maximum number of topics that can be published This must be greater than 0, or the code will fail to compile. It also must be a power of two, or the software may behave incorrectly.R
: The maximum number of services for which requests can be sent This must be greater than 0, or the code will fail to compile. It also must be a power of two, or the software may behave incorrectly.
Implementations§
source§impl<C, T, U, N, TR, D, const P: usize, const R: usize> CoreNode<C, T, U, TR, D, P, R>where
C: Clock,
N: Transport,
U: Receiver<C, Transport = N, Driver = D>,
T: Transmitter<C, Transport = N, Driver = D>,
TR: TransferIdTracker<N>,
impl<C, T, U, N, TR, D, const P: usize, const R: usize> CoreNode<C, T, U, TR, D, P, R>where C: Clock, N: Transport, U: Receiver<C, Transport = N, Driver = D>, T: Transmitter<C, Transport = N, Driver = D>, TR: TransferIdTracker<N>,
sourcepub fn new(
clock: C,
node_id: <T::Transport as Transport>::NodeId,
transmitter: T,
receiver: U,
driver: D
) -> Self
pub fn new( clock: C, node_id: <T::Transport as Transport>::NodeId, transmitter: T, receiver: U, driver: D ) -> Self
Creates a node
clock
: A clock to use for frame deadlines and timeoutsnode_id
: The ID of this nodetransmitter
: A transport transmitterreceiver
: A transport receiverdriver
: A driver compatible withreceiver
andtransmitter
sourcepub fn driver_mut(&mut self) -> &mut D
pub fn driver_mut(&mut self) -> &mut D
Returns a mutable reference to the enclosed driver
Trait Implementations§
source§impl<C, T, U, TR: Debug, D: Debug, const P: usize, const R: usize> Debug for CoreNode<C, T, U, TR, D, P, R>where
C: Clock + Debug,
U: Receiver<C> + Debug,
T: Transmitter<C> + Debug,
T::Transport: Debug,
impl<C, T, U, TR: Debug, D: Debug, const P: usize, const R: usize> Debug for CoreNode<C, T, U, TR, D, P, R>where C: Clock + Debug, U: Receiver<C> + Debug, T: Transmitter<C> + Debug, T::Transport: Debug,
source§impl<C, T, U, N, TR, D, const P: usize, const R: usize> Node for CoreNode<C, T, U, TR, D, P, R>where
C: Clock,
N: Transport,
T: Transmitter<C, Transport = N, Driver = D>,
U: Receiver<C, Transport = N, Driver = D>,
TR: TransferIdTracker<N>,
impl<C, T, U, N, TR, D, const P: usize, const R: usize> Node for CoreNode<C, T, U, TR, D, P, R>where C: Clock, N: Transport, T: Transmitter<C, Transport = N, Driver = D>, U: Receiver<C, Transport = N, Driver = D>, TR: TransferIdTracker<N>,
source§fn start_sending_requests<M>(
&mut self,
service: ServiceId,
receive_timeout: <C::Instant as Instant>::Duration,
response_payload_size_max: usize,
priority: N::Priority
) -> Result<ServiceToken<M>, StartSendError<U::Error>>where
M: Request,
fn start_sending_requests<M>( &mut self, service: ServiceId, receive_timeout: <C::Instant as Instant>::Duration, response_payload_size_max: usize, priority: N::Priority ) -> Result<ServiceToken<M>, StartSendError<U::Error>>where M: Request,
Sets up to send requests for a service
This also subscribes to the corresponding responses.
source§fn node_id(&self) -> <Self::Transport as Transport>::NodeId
fn node_id(&self) -> <Self::Transport as Transport>::NodeId
Returns the identifier of this node
§type Transmitter = T
type Transmitter = T
The transmitter that this node uses
source§fn receive<H>(&mut self, handler: &mut H) -> Result<(), U::Error>where
H: TransferHandler<Self::Instant, Self::Transport>,
fn receive<H>(&mut self, handler: &mut H) -> Result<(), U::Error>where H: TransferHandler<Self::Instant, Self::Transport>,
Receives any available incoming frames and attempts ot reassemble them into a transfer Read more
source§fn start_publishing<M>(
&mut self,
subject: SubjectId,
timeout: <C::Instant as Instant>::Duration,
priority: N::Priority
) -> Result<PublishToken<M>, StartSendError<T::Error>>where
M: Message,
fn start_publishing<M>( &mut self, subject: SubjectId, timeout: <C::Instant as Instant>::Duration, priority: N::Priority ) -> Result<PublishToken<M>, StartSendError<T::Error>>where M: Message,
Starts publishing messages on subject Read more
source§fn stop_publishing<M>(&mut self, token: PublishToken<M>)where
M: Message,
fn stop_publishing<M>(&mut self, token: PublishToken<M>)where M: Message,
Stops publishing messages on a subject
source§fn publish<M>(
&mut self,
token: &PublishToken<M>,
payload: &M
) -> Result<(), T::Error>where
M: Message + Serialize,
fn publish<M>( &mut self, token: &PublishToken<M>, payload: &M ) -> Result<(), T::Error>where M: Message + Serialize,
Publishes a message Read more
source§fn publish_loopback<M>(
&mut self,
token: &PublishToken<M>,
payload: &M
) -> Result<(), T::Error>where
M: Message + Serialize,
fn publish_loopback<M>( &mut self, token: &PublishToken<M>, payload: &M ) -> Result<(), T::Error>where M: Message + Serialize,
Publishes a message with the loopback flag set to true Read more
source§fn stop_sending_requests<M>(&mut self, token: ServiceToken<M>)where
M: Request,
fn stop_sending_requests<M>(&mut self, token: ServiceToken<M>)where M: Request,
Stops sending requests for a service
source§fn send_request<M>(
&mut self,
token: &ServiceToken<M>,
payload: &M,
destination: N::NodeId
) -> Result<N::TransferId, T::Error>where
M: Request + Serialize,
fn send_request<M>( &mut self, token: &ServiceToken<M>, payload: &M, destination: N::NodeId ) -> Result<N::TransferId, T::Error>where M: Request + Serialize,
Sends a service request to another node Read more
source§fn send_request_loopback<M>(
&mut self,
token: &ServiceToken<M>,
payload: &M,
destination: <Self::Transport as Transport>::NodeId
) -> Result<<Self::Transport as Transport>::TransferId, <Self::Transmitter as Transmitter<Self::Clock>>::Error>where
M: Request + Serialize,
fn send_request_loopback<M>( &mut self, token: &ServiceToken<M>, payload: &M, destination: <Self::Transport as Transport>::NodeId ) -> Result<<Self::Transport as Transport>::TransferId, <Self::Transmitter as Transmitter<Self::Clock>>::Error>where M: Request + Serialize,
Sends a service request to another node, with the loopback flag set to true Read more
source§fn subscribe_message(
&mut self,
subject: SubjectId,
payload_size_max: usize,
timeout: <C::Instant as Instant>::Duration
) -> Result<(), U::Error>
fn subscribe_message( &mut self, subject: SubjectId, payload_size_max: usize, timeout: <C::Instant as Instant>::Duration ) -> Result<(), U::Error>
Subscribes to messages on a topic
source§fn subscribe_request(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <C::Instant as Instant>::Duration
) -> Result<(), U::Error>
fn subscribe_request( &mut self, service: ServiceId, payload_size_max: usize, timeout: <C::Instant as Instant>::Duration ) -> Result<(), U::Error>
Subscribes to requests for a service
source§fn send_response<M>(
&mut self,
token: ResponseToken<Self::Transport>,
timeout: <C::Instant as Instant>::Duration,
payload: &M
) -> Result<(), T::Error>where
M: Response + Serialize,
fn send_response<M>( &mut self, token: ResponseToken<Self::Transport>, timeout: <C::Instant as Instant>::Duration, payload: &M ) -> Result<(), T::Error>where M: Response + Serialize,
Responds to a service request Read more
source§fn transmitter(&self) -> &Self::Transmitter
fn transmitter(&self) -> &Self::Transmitter
Returns a reference to the transport transmitter
source§fn transmitter_mut(&mut self) -> &mut Self::Transmitter
fn transmitter_mut(&mut self) -> &mut Self::Transmitter
Returns a mutable reference to the transport transmitter
source§fn receiver_mut(&mut self) -> &mut Self::Receiver
fn receiver_mut(&mut self) -> &mut Self::Receiver
Returns a mutable reference to the transport receiver
Auto Trait Implementations§
impl<C, T, U, TR, D, const P: usize, const R: usize> RefUnwindSafe for CoreNode<C, T, U, TR, D, P, R>where C: RefUnwindSafe, D: RefUnwindSafe, T: RefUnwindSafe, TR: RefUnwindSafe, U: RefUnwindSafe, <<C as Clock>::Instant as Instant>::Duration: RefUnwindSafe, <<T as Transmitter<C>>::Transport as Transport>::NodeId: RefUnwindSafe, <<T as Transmitter<C>>::Transport as Transport>::Priority: RefUnwindSafe, <<T as Transmitter<C>>::Transport as Transport>::TransferId: RefUnwindSafe,
impl<C, T, U, TR, D, const P: usize, const R: usize> Send for CoreNode<C, T, U, TR, D, P, R>where C: Send, D: Send, T: Send, TR: Send, U: Send, <<C as Clock>::Instant as Instant>::Duration: Send, <<T as Transmitter<C>>::Transport as Transport>::NodeId: Send, <<T as Transmitter<C>>::Transport as Transport>::Priority: Send, <<T as Transmitter<C>>::Transport as Transport>::TransferId: Send,
impl<C, T, U, TR, D, const P: usize, const R: usize> Sync for CoreNode<C, T, U, TR, D, P, R>where C: Sync, D: Sync, T: Sync, TR: Sync, U: Sync, <<C as Clock>::Instant as Instant>::Duration: Sync, <<T as Transmitter<C>>::Transport as Transport>::NodeId: Sync, <<T as Transmitter<C>>::Transport as Transport>::Priority: Sync, <<T as Transmitter<C>>::Transport as Transport>::TransferId: Sync,
impl<C, T, U, TR, D, const P: usize, const R: usize> Unpin for CoreNode<C, T, U, TR, D, P, R>where C: Unpin, D: Unpin, T: Unpin, TR: Unpin, U: Unpin, <<C as Clock>::Instant as Instant>::Duration: Unpin, <<T as Transmitter<C>>::Transport as Transport>::NodeId: Unpin, <<T as Transmitter<C>>::Transport as Transport>::Priority: Unpin, <<T as Transmitter<C>>::Transport as Transport>::TransferId: Unpin,
impl<C, T, U, TR, D, const P: usize, const R: usize> UnwindSafe for CoreNode<C, T, U, TR, D, P, R>where C: UnwindSafe, D: UnwindSafe, T: UnwindSafe, TR: UnwindSafe, U: UnwindSafe, <<C as Clock>::Instant as Instant>::Duration: UnwindSafe, <<T as Transmitter<C>>::Transport as Transport>::NodeId: UnwindSafe, <<T as Transmitter<C>>::Transport as Transport>::Priority: UnwindSafe, <<T as Transmitter<C>>::Transport as Transport>::TransferId: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more