[−][src]Trait ublox_cellular::prelude::TcpClient
This trait is implemented by TCP/IP stacks. You could, for example, have an implementation
which knows how to send AT commands to an ESP8266 WiFi module. You could have another implementation
which knows how to driver the Rust Standard Library's std::net
module. Given this trait, you can how
write a portable HTTP client which can work with either implementation.
Associated Types
type TcpSocket
[src]
The type returned when we create a new TCP socket
type Error: Debug
[src]
The type returned when we have an error
Required methods
pub fn socket(&self) -> Result<Self::TcpSocket, Self::Error>
[src]
Open a socket for usage as a TCP client.
The socket must be connected before it can be used.
Returns Ok(socket)
if the socket was successfully created.
pub fn connect(
&self,
socket: &mut Self::TcpSocket,
remote: SocketAddr
) -> Result<(), Error<Self::Error>>
[src]
&self,
socket: &mut Self::TcpSocket,
remote: SocketAddr
) -> Result<(), Error<Self::Error>>
Connect to the given remote host and port.
Returns Ok
if the connection was successful. Otherwise, if the connection could not be
completed immediately, this function should return nb::Error::WouldBlock
.
pub fn is_connected(
&self,
socket: &Self::TcpSocket
) -> Result<bool, Self::Error>
[src]
&self,
socket: &Self::TcpSocket
) -> Result<bool, Self::Error>
Check if this socket is connected
pub fn send(
&self,
socket: &mut Self::TcpSocket,
buffer: &[u8]
) -> Result<usize, Error<Self::Error>>
[src]
&self,
socket: &mut Self::TcpSocket,
buffer: &[u8]
) -> Result<usize, Error<Self::Error>>
Write to the stream.
Returns the number of bytes written (which may be less than buffer.len()
) or an error.
pub fn receive(
&self,
socket: &mut Self::TcpSocket,
buffer: &mut [u8]
) -> Result<usize, Error<Self::Error>>
[src]
&self,
socket: &mut Self::TcpSocket,
buffer: &mut [u8]
) -> Result<usize, Error<Self::Error>>
Receive data from the stream.
Returns Ok(n)
, which means n
bytes of data have been received and
they have been placed in &buffer[0..n]
, or an error. If a packet has
not been received when called, then nb::Error::WouldBlock
should be returned.
pub fn close(&self, socket: Self::TcpSocket) -> Result<(), Self::Error>
[src]
Close an existing TCP socket.