AppFace

Struct AppFace 

Source
pub struct AppFace { /* private fields */ }
Expand description

In-process NDN face backed by a pair of tokio::sync::mpsc channels.

AppFace is held by the forwarder pipeline; AppHandle is given to the application (library user). The forwarder sends packets to the app via AppFace::sendapp_tx; the app sends packets to the forwarder via AppHandle::sendface_tx.

  pipeline            application
  ────────            ───────────
  AppFace::recv()  ←  AppHandle::send()   (face_rx ← face_tx)
  AppFace::send()  →  AppHandle::recv()   (app_tx  → app_rx)

face_rx is wrapped in a Mutex to satisfy the &self requirement of the Face trait; the pipeline’s single-consumer contract means it never actually contends.

Implementations§

Source§

impl AppFace

Source

pub fn new(id: FaceId, buffer: usize) -> (Self, AppHandle)

Create a linked (AppFace, AppHandle) pair with buffer slots each.

Trait Implementations§

Source§

impl Face for AppFace

Source§

async fn recv(&self) -> Result<Bytes, FaceError>

Receive a packet sent by the application via AppHandle::send.

Source§

async fn send(&self, pkt: Bytes) -> Result<(), FaceError>

Forward a packet to the application (readable via AppHandle::recv).

Source§

fn id(&self) -> FaceId

Source§

fn kind(&self) -> FaceKind

Source§

fn remote_uri(&self) -> Option<String>

Remote URI (e.g. udp4://192.168.1.1:6363). Returns None for face types that don’t have a meaningful remote endpoint.
Source§

fn local_uri(&self) -> Option<String>

Local URI (e.g. unix:///tmp/ndn.sock). Returns None for face types that don’t expose local binding info.
Source§

fn recv_with_addr( &self, ) -> impl Future<Output = Result<(Bytes, Option<FaceAddr>), FaceError>> + Send

Receive the next packet together with the link-layer sender address. Read more

Auto Trait Implementations§

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<F> ErasedFace for F
where F: Face,

Source§

fn id(&self) -> FaceId

Source§

fn kind(&self) -> FaceKind

Source§

fn remote_uri(&self) -> Option<String>

Source§

fn local_uri(&self) -> Option<String>

Source§

fn send_bytes( &self, pkt: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), FaceError>> + Send + '_>>

Source§

fn recv_bytes( &self, ) -> Pin<Box<dyn Future<Output = Result<Bytes, FaceError>> + Send + '_>>

Source§

fn recv_bytes_with_addr( &self, ) -> Pin<Box<dyn Future<Output = Result<(Bytes, Option<FaceAddr>), FaceError>> + Send + '_>>

Object-safe version of Face::recv_with_addr. 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 = 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 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.