Struct canadensis::node::BasicNode
source · [−]pub struct BasicNode<N> where
N: Node, { /* private fields */ }
Expand description
A node that provides all basic application-layer functionality
This node performs the following functions:
- Sending a
uavcan.node.Heartbeat
every second - Responding to
uavcan.node.GetInfo
requests - Sending a
uavcan.node.port.List
message every 10 seconds
A BasicNode uses up two publisher slots in the underlying node.
The underlying node type N
is usually a CoreNode
.
Implementations
sourceimpl<N> BasicNode<N> where
N: Node,
impl<N> BasicNode<N> where
N: Node,
sourcepub fn new(
node: N,
node_info: GetInfoResponse
) -> Result<Self, NodeError<StartSendError<<N::Transmitter as Transmitter<N::Instant>>::Error>, <N::Receiver as Receiver<N::Instant>>::Error>>
pub fn new(
node: N,
node_info: GetInfoResponse
) -> Result<Self, NodeError<StartSendError<<N::Transmitter as Transmitter<N::Instant>>::Error>, <N::Receiver as Receiver<N::Instant>>::Error>>
Creates a new basic node
node
: The underlying node (this is usually aCoreNode
)node_info
: The information that should be returned when handling node information requests
sourcepub fn run_per_second_tasks(
&mut self
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error>
pub fn run_per_second_tasks(
&mut self
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error>
This function must be called once per second to send heartbeat and port list messages
sourcepub fn set_mode(&mut self, mode: Mode)
pub fn set_mode(&mut self, mode: Mode)
Sets the operating mode that will be reported in the heartbeat messages
sourcepub fn set_health(&mut self, health: Health)
pub fn set_health(&mut self, health: Health)
Sets the health status that will be reported in the heartbeat messages
sourcepub fn set_status_code(&mut self, status: u8)
pub fn set_status_code(&mut self, status: u8)
Sets the vendor-specific status code that will be reported in the heartbeat messages
Trait Implementations
sourceimpl<N> Node for BasicNode<N> where
N: Node,
impl<N> Node for BasicNode<N> where
N: Node,
type Transmitter = N::Transmitter
type Transmitter = N::Transmitter
The transmitter that this node uses
sourcefn receive<H>(
&mut self,
handler: &mut H
) -> Result<(), <N::Receiver as Receiver<N::Instant>>::Error> where
H: TransferHandler<Self::Instant, Self::Transport>,
fn receive<H>(
&mut self,
handler: &mut H
) -> Result<(), <N::Receiver as Receiver<N::Instant>>::Error> where
H: TransferHandler<Self::Instant, Self::Transport>,
Receives any available incoming frames and attempts ot reassemble them into a transfer Read more
sourcefn start_publishing<T>(
&mut self,
subject: SubjectId,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration,
priority: <Self::Transport as Transport>::Priority
) -> Result<PublishToken<T>, StartSendError<<N::Transmitter as Transmitter<N::Instant>>::Error>> where
T: Message,
fn start_publishing<T>(
&mut self,
subject: SubjectId,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration,
priority: <Self::Transport as Transport>::Priority
) -> Result<PublishToken<T>, StartSendError<<N::Transmitter as Transmitter<N::Instant>>::Error>> where
T: Message,
Starts publishing messages on subject Read more
sourcefn stop_publishing<T>(&mut self, token: PublishToken<T>) where
T: Message,
fn stop_publishing<T>(&mut self, token: PublishToken<T>) where
T: Message,
Stops publishing messages on a subject
sourcefn publish<T>(
&mut self,
token: &PublishToken<T>,
payload: &T
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error> where
T: Message + Serialize,
fn publish<T>(
&mut self,
token: &PublishToken<T>,
payload: &T
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error> where
T: Message + Serialize,
Publishes a message Read more
sourcefn start_sending_requests<T>(
&mut self,
service: ServiceId,
receive_timeout: <<N::Clock as Clock>::Instant as Instant>::Duration,
response_payload_size_max: usize,
priority: <Self::Transport as Transport>::Priority
) -> Result<ServiceToken<T>, StartSendError<<N::Receiver as Receiver<N::Instant>>::Error>> where
T: Request,
fn start_sending_requests<T>(
&mut self,
service: ServiceId,
receive_timeout: <<N::Clock as Clock>::Instant as Instant>::Duration,
response_payload_size_max: usize,
priority: <Self::Transport as Transport>::Priority
) -> Result<ServiceToken<T>, StartSendError<<N::Receiver as Receiver<N::Instant>>::Error>> where
T: Request,
Sets up to send requests for a service Read more
sourcefn stop_sending_requests<T>(&mut self, token: ServiceToken<T>) where
T: Request,
fn stop_sending_requests<T>(&mut self, token: ServiceToken<T>) where
T: Request,
Stops sending requests for a service
sourcefn send_request<T>(
&mut self,
token: &ServiceToken<T>,
payload: &T,
destination: <Self::Transport as Transport>::NodeId
) -> Result<<Self::Transport as Transport>::TransferId, <N::Transmitter as Transmitter<N::Instant>>::Error> where
T: Request + Serialize,
fn send_request<T>(
&mut self,
token: &ServiceToken<T>,
payload: &T,
destination: <Self::Transport as Transport>::NodeId
) -> Result<<Self::Transport as Transport>::TransferId, <N::Transmitter as Transmitter<N::Instant>>::Error> where
T: Request + Serialize,
Sends a service request to another node Read more
sourcefn subscribe_message(
&mut self,
subject: SubjectId,
payload_size_max: usize,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration
) -> Result<(), <N::Receiver as Receiver<N::Instant>>::Error>
fn subscribe_message(
&mut self,
subject: SubjectId,
payload_size_max: usize,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration
) -> Result<(), <N::Receiver as Receiver<N::Instant>>::Error>
Subscribes to messages on a topic
sourcefn subscribe_request(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration
) -> Result<(), <N::Receiver as Receiver<N::Instant>>::Error>
fn subscribe_request(
&mut self,
service: ServiceId,
payload_size_max: usize,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration
) -> Result<(), <N::Receiver as Receiver<N::Instant>>::Error>
Subscribes to requests for a service
sourcefn send_response<T>(
&mut self,
token: ResponseToken<Self::Transport>,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration,
payload: &T
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error> where
T: Response + Serialize,
fn send_response<T>(
&mut self,
token: ResponseToken<Self::Transport>,
timeout: <<N::Clock as Clock>::Instant as Instant>::Duration,
payload: &T
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error> where
T: Response + Serialize,
Responds to a service request Read more
sourcefn flush(
&mut self
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error>
fn flush(
&mut self
) -> Result<(), <N::Transmitter as Transmitter<N::Instant>>::Error>
Attempts to flush all outgoing frames
sourcefn transmitter(&self) -> &Self::Transmitter
fn transmitter(&self) -> &Self::Transmitter
Returns a reference to the transport transmitter
sourcefn transmitter_mut(&mut self) -> &mut Self::Transmitter
fn transmitter_mut(&mut self) -> &mut Self::Transmitter
Returns a mutable reference to the transport transmitter
sourcefn 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<N> RefUnwindSafe for BasicNode<N> where
N: RefUnwindSafe,
impl<N> Send for BasicNode<N> where
N: Send,
impl<N> Sync for BasicNode<N> where
N: Sync,
impl<N> Unpin for BasicNode<N> where
N: Unpin,
impl<N> UnwindSafe for BasicNode<N> where
N: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more