Skip to main content

Port

Struct Port 

Source
pub struct Port { /* private fields */ }
Available on crate feature hub only.
Expand description

One attachment point on a Hub.

A port is both a sender and a receiver. It is the building block for custom transports: read frames from your connection and send them, and write every frame from recv back to it.

Implementations§

Source§

impl Port

Source

pub fn id(&self) -> u64

A process-unique identifier for this port (used for no-echo filtering and in log messages).

Source

pub fn send(&self, frame: CanFrame)

Send a frame to every other port.

Never blocks. If no other port is attached the frame is discarded.

Source

pub async fn recv(&mut self) -> Option<CanFrame>

Wait for the next frame from another port. Returns None if the hub is gone.

If this port fell more than CHANNEL_DEPTH frames behind, the frames it missed are skipped (and logged with the log feature) and reception continues with the oldest frame still in the ring.

Source

pub fn try_recv(&mut self) -> Option<CanFrame>

Return a frame if one is ready, without waiting. Lag is handled exactly as in Port::recv.

Trait Implementations§

Source§

impl Debug for Port

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Port

§

impl RefUnwindSafe for Port

§

impl Send for Port

§

impl Sync for Port

§

impl Unpin for Port

§

impl UnsafeUnpin for Port

§

impl UnwindSafe for Port

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.