Struct bluer::l2cap::SeqPacket

source ·
pub struct SeqPacket { /* private fields */ }
Available on crate feature l2cap only.
Expand description

An L2CAP sequential packet socket (sequenced, reliable, two-way connection-based data transmission path for datagrams of fixed maximum length).

Implementations§

source§

impl SeqPacket

source

pub async fn connect(addr: SocketAddr) -> Result<Self>

Establish a sequential packet connection with a peer at the specified socket address.

Uses any local Bluetooth adapter.

source

pub fn peer_addr(&self) -> Result<SocketAddr>

Gets the peer address of this stream.

source

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

Sends a packet.

The packet length must not exceed the Self::send_mtu.

source

pub fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>

Attempts to send a packet.

The packet length must not exceed the Self::send_mtu.

source

pub async fn recv(&self, buf: &mut [u8]) -> Result<usize>

Receives a packet.

The provided buffer must be of length Self::recv_mtu, otherwise the packet may be truncated.

source

pub fn poll_recv( &self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_> ) -> Poll<Result<()>>

Attempts to receive a packet.

The provided buffer must be of length Self::recv_mtu, otherwise the packet may be truncated.

source

pub fn shutdown(&self, how: Shutdown) -> Result<()>

Shuts down the read, write, or both halves of this connection.

source

pub fn send_mtu(&self) -> Result<usize>

Maximum transmission unit (MTU) for sending.

source

pub fn recv_mtu(&self) -> Result<usize>

Maximum transmission unit (MTU) for receiving.

source

pub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>

Constructs a new SeqPacket from the given raw file descriptor.

The file descriptor must have been set to non-blocking mode.

This function consumes ownership of the specified file descriptor. The returned object will take responsibility for closing it when the object goes out of scope.

§Safety

If the passed file descriptor is invalid, undefined behavior may occur.

Trait Implementations§

source§

impl AsRawFd for SeqPacket

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl AsRef<Socket<SeqPacket>> for SeqPacket

source§

fn as_ref(&self) -> &Socket<SeqPacket>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for SeqPacket

source§

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

Formats the value using the given formatter. Read more
source§

impl FromRawFd for SeqPacket

source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor.

The file descriptor must have been set to non-blocking mode.

§Panics

Panics when the conversion fails. Use SeqPacket::from_raw_fd for a non-panicking variant.

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

§

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

§

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.