pub struct Socket { /* private fields */ }
rfcomm
only.Expand description
Implementations
sourceimpl Socket
impl Socket
sourcepub fn listen(self, backlog: u32) -> Result<Listener>
pub fn listen(self, backlog: u32) -> Result<Listener>
Convert the socket into a Listener.
backlog
defines the maximum number of pending connections are queued by the operating system
at any given time.
This will not register an SDP record for this channel. Register a Bluetooth RFCOMM profile instead, if you need a service record.
sourcepub async fn connect(self, sa: SocketAddr) -> Result<Stream>
pub async fn connect(self, sa: SocketAddr) -> Result<Stream>
Establish a stream connection with a peer at the specified socket address.
This requires knowledge of the channel number. Register a Bluetooth RFCOMM profile, if you need to discover the channel number using a service record.
sourcepub fn bind(&self, sa: SocketAddr) -> Result<()>
pub fn bind(&self, sa: SocketAddr) -> Result<()>
Bind the socket to the given address.
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Get the local address of this socket.
sourcepub fn security(&self) -> Result<Security>
pub fn security(&self) -> Result<Security>
Get socket security.
This corresponds to the BT_SECURITY
socket option.
sourcepub fn set_security(&self, security: Security) -> Result<()>
pub fn set_security(&self, security: Security) -> Result<()>
Set socket security.
This corresponds to the BT_SECURITY
socket option.
sourcepub fn recv_buffer(&self) -> Result<i32>
pub fn recv_buffer(&self) -> Result<i32>
Gets the maximum socket receive buffer in bytes.
This corresponds to the SO_RCVBUF
socket option.
sourcepub fn set_recv_buffer(&self, recv_buffer: i32) -> Result<()>
pub fn set_recv_buffer(&self, recv_buffer: i32) -> Result<()>
Sets the maximum socket receive buffer in bytes.
This corresponds to the SO_RCVBUF
socket option.
sourcepub fn conn_info(&self) -> Result<ConnInfo>
pub fn conn_info(&self) -> Result<ConnInfo>
Gets the RFCOMM socket connection information.
This corresponds to the RFCOMM_CONNINFO
socket option.
sourcepub fn is_master(&self) -> Result<bool>
pub fn is_master(&self) -> Result<bool>
Gets whether the RFCOMM socket is the master.
This corresponds to the RFCOMM_LM
socket option and option bit RFCOMM_LM_MASTER
.
sourcepub fn set_master(&self, master: bool) -> Result<()>
pub fn set_master(&self, master: bool) -> Result<()>
sets whether the RFCOMM socket is the master.
This corresponds to the RFCOMM_LM
socket option and option bit RFCOMM_LM_MASTER
.
sourcepub fn input_buffer(&self) -> Result<u32>
pub fn input_buffer(&self) -> Result<u32>
Get the number of bytes in the input buffer.
This corresponds to the TIOCINQ
IOCTL.
sourcepub fn output_buffer(&self) -> Result<u32>
pub fn output_buffer(&self) -> Result<u32>
Get the number of bytes in the output buffer.
This corresponds to the TIOCOUTQ
IOCTL.
sourcepub fn create_tty(&self, dev_id: i16) -> Result<i16>
pub fn create_tty(&self, dev_id: i16) -> Result<i16>
Creates a TTY (virtual serial port) for this RFCOMM connection.
Set dev_id
to -1 to automatically allocate an id.
Returns the allocated device id.
This corresponds to the RFCOMMCREATEDEV
IOCTL.
sourcepub fn release_tty(dev_id: i16) -> Result<()>
pub fn release_tty(dev_id: i16) -> Result<()>
Releases a TTY (virtual serial port) for this RFCOMM connection.
This corresponds to the RFCOMMRELEASEDEV
IOCTL.
sourcepub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>
pub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>
Constructs a new Socket 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 Socket
impl FromRawFd for Socket
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 Socket::from_raw_fd for a non-panicking variant.
Auto Trait Implementations
impl !RefUnwindSafe for Socket
impl Send for Socket
impl Sync for Socket
impl Unpin for Socket
impl !UnwindSafe for Socket
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more