Skip to main content

L2capChannel

Struct L2capChannel 

Source
pub struct L2capChannel<C: PlatformChannel> { /* private fields */ }
Expand description

An open L2CAP channel. Closes on drop.

Implementations§

Source§

impl<C: PlatformChannel> L2capChannel<C>

Source

pub fn new(channel: C, sink: Arc<Sink>, incoming: Incoming) -> Self

Wrap a platform socket that was opened with sink’s first value.

Source

pub fn psm(&self) -> Psm

The channel’s PSM.

Source

pub fn peer_id(&self) -> &str

The peer’s per-host identifier.

Source

pub fn take_incoming(&self) -> Option<Incoming>

Take the inbound byte stream. None on a second call — there is one stream and consuming it twice would split the bytes between consumers.

Source

pub fn send(&self, bytes: &[u8]) -> Result<()>

Queue bytes for sending.

Returns once queued, not once on the air; the pump writes them as the peer grants credit. Use L2capChannel::flushed to wait for the queue to drain.

Source

pub fn pending_bytes(&self) -> usize

How many queued bytes have not been written yet.

Source

pub async fn flushed(&self) -> Result<()>

Wait until everything queued has been written, or the channel closes.

Polls, because NSOutputStream reports space rather than completion.

Source

pub fn closed(&self) -> Option<Closed>

Why the channel closed, or None while it is open.

Source

pub async fn on_close(&self) -> Closed

Resolve when the channel closes, with the reason.

Source

pub fn close(&self)

Close the channel.

Trait Implementations§

Source§

impl<C: PlatformChannel> Debug for L2capChannel<C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> !Freeze for L2capChannel<C>

§

impl<C> Forget for L2capChannel<C>

§

impl<C> Move for L2capChannel<C>

§

impl<C> RefUnwindSafe for L2capChannel<C>
where C: RefUnwindSafe,

§

impl<C> Send for L2capChannel<C>

§

impl<C> Sync for L2capChannel<C>

§

impl<C> Unpin for L2capChannel<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for L2capChannel<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for L2capChannel<C>
where C: UnwindSafe,

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.