pub struct SeqPacket { /* private fields */ }
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
sourceimpl SeqPacket
impl SeqPacket
sourcepub async fn connect(addr: SocketAddr) -> Result<Self>
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.
sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Gets the peer address of this stream.
sourcepub async fn send(&self, buf: &[u8]) -> Result<usize>
pub async fn send(&self, buf: &[u8]) -> Result<usize>
Sends a packet.
The packet length must not exceed the Self::send_mtu.
sourcepub fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>
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.
sourcepub async fn recv(&self, buf: &mut [u8]) -> Result<usize>
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.
sourcepub fn poll_recv(
&self,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>
) -> Poll<Result<()>>
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.
sourcepub fn shutdown(&self, how: Shutdown) -> Result<()>
pub fn shutdown(&self, how: Shutdown) -> Result<()>
Shuts down the read, write, or both halves of this connection.
sourcepub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>
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
sourceimpl FromRawFd for SeqPacket
impl FromRawFd for SeqPacket
sourceunsafe fn from_raw_fd(fd: RawFd) -> Self
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.