Crate asio [−] [src]
The asio is Asynchronous Input/Output library.
Usage
This crate is on github and can be used by adding asio
to the dependencies in your project's Cargo.toml.
[dependencies]
rust_asio = "*"
And this in your crate root:
extern crate asio;
For example, Connection with TCP socket code:
use std::io; use asio::*; use asio::ip::*; struct TcpClient(TcpSocket); impl TcpClient { fn start(io: &IoService) { let soc = Strand::new(io, TcpClient(TcpSocket::new(io, Tcp::v4()).unwrap())); let ep = TcpEndpoint::new(IpAddrV4::new(192,168,0,1), 12345); soc.0.async_connect(&ep, Self::on_connect, &soc); } fn on_connect(soc: Strand<Self>, res: io::Result<()>) { match res { Ok(_) => println!("connected."), Err(err) => println!("{:?}", err), } } } fn main() { let io = IoService::new(); TcpClient::start(&io); //io.run(); }
Modules
ip |
An internet protocol and sockets. |
local |
A local protocol and sockets. |
socket_base |
Provides some of the socket control commands. |
Structs
DgramSocket |
Provides datagram-oriented socket functionality. |
IoService |
The core I/O process. |
RawSocket |
Provides raw-oriented socket functionality. |
SeqPacketSocket |
Provides sequenced packet socket functionality. |
SocketListener |
Provides the ability to accept new connections. |
SteadyClock | |
Strand |
Serialized object for an |
StreamBuf | |
StreamSocket |
Provides stream-oriented socket functionality. |
SystemClock | |
WaitTimer |
Enums
Shutdown |
Possible values which can be passed to the shutdown method. |
Traits
AsSockAddr | |
Clock | |
Endpoint | |
GetSocketOption | |
IoControl | |
IoObject |
Traits to the associated with |
MatchCondition | |
NonBlocking | |
Protocol | |
SetSocketOption | |
SocketOption |
Functions
async_read_until | |
async_write_until | |
read_until | |
write_until |
Type Definitions
SteadyTimer | |
SystemTimer |