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 time
  • T: The transmitter used to send transfers
  • U: The receiver used to receive transfers
  • TR: The transfer ID tracker used to manage transfer IDs for outgoing transfers
  • D: The driver used to send and receive frames
  • P: 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>,

source

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 timeouts
  • node_id: The ID of this node
  • transmitter: A transport transmitter
  • receiver: A transport receiver
  • driver: A driver compatible with receiver and transmitter
source

pub fn driver(&self) -> &D

Returns a reference to the enclosed driver

source

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,

source§

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

Formats the value using the given formatter. Read more
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>,

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,

Sets up to send requests for a service

This also subscribes to the corresponding responses.

source§

fn clock(&self) -> &C

Returns a reference to the enclosed clock

source§

fn clock_mut(&mut self) -> &mut C

Returns a mutable reference to the enclosed clock

source§

fn node_id(&self) -> <Self::Transport as Transport>::NodeId

Returns the identifier of this node

§

type Clock = C

The clock that this node uses
§

type Instant = <C as Clock>::Instant

The instant that this node’s clock produces
§

type Transport = N

The transport that this node uses
§

type Transmitter = T

The transmitter that this node uses
§

type Receiver = U

The receiver that this node uses
source§

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,

Starts publishing messages on subject Read more
source§

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,

Publishes a message Read more
source§

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,

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,

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,

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>

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>

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,

Responds to a service request Read more
source§

fn flush(&mut self) -> Result<(), T::Error>

Attempts to flush all outgoing frames
source§

fn transmitter(&self) -> &Self::Transmitter

Returns a reference to the transport transmitter
source§

fn transmitter_mut(&mut self) -> &mut Self::Transmitter

Returns a mutable reference to the transport transmitter
source§

fn receiver(&self) -> &Self::Receiver

Returns a reference to the transport receiver
source§

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> 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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.
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.
source§

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

Performs the conversion.