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

An L2CAP datagram socket (connection-less, unreliable messages of a fixed maximum length).

Implementations

Creates a new datagram socket, which will be bound to the specified socket address.

Specify SocketAddr::any_br_edr or SocketAddr::any_le for any local adapter address with a dynamically allocated PSM.

Establish a datagram connection with a peer at the specified socket address.

Gets the peer address of this stream.

Sends a packet to the connected peer.

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

Attempts to send a packet to the connected peer.

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

Sends a packet to the specified target address.

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

Attempts to send a packet to the specified target address.

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

Receives a packet from the connected peer.

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

Attempts to receive a packet from the connected peer.

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

Receives a packet from anywhere.

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

Attempts to receive a packet from anywhere.

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

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

Maximum transmission unit (MTU) for sending.

Maximum transmission unit (MTU) for receiving.

Constructs a new Datagram 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

Extracts the raw file descriptor. Read more

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

Formats the value using the given formatter. Read more

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 Datagram::from_raw_fd for a non-panicking variant.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.