#ipc #packet #servo #c #share #sharing

packet-ipc

Share packets between services using servo ipc

13 breaking releases

new 0.14.0 Sep 24, 2020
0.13.0 Jul 2, 2020
0.12.0 Jun 1, 2020
0.9.0 Feb 21, 2020
0.4.0 Mar 22, 2019

#71 in Asynchronous

Download history 58/week @ 2020-06-04 42/week @ 2020-06-11 73/week @ 2020-06-18 73/week @ 2020-06-25 214/week @ 2020-07-02 63/week @ 2020-07-09 91/week @ 2020-07-16 64/week @ 2020-07-23 161/week @ 2020-07-30 56/week @ 2020-08-06 205/week @ 2020-08-13 152/week @ 2020-08-20 78/week @ 2020-08-27 151/week @ 2020-09-03 211/week @ 2020-09-10 138/week @ 2020-09-17

559 downloads per month
Used in suricata-ipc

MIT license

12KB
245 lines

packet-ipc

build status crates.io version docs.rs docs MIT licensed

Library to share packets between processes using servo's ipc-channel.

Attempts to be as efficient as possible while still allowing packets to be used with C FFI.

A packet is defined for this library as any structure which implements AsIpcPacket.

Usage

A server must be created before a client, since the client will use the server's name to connect.

To start, create a server, and accept a connection:

let server = Server::new().expect("Failed to build server");
let server_name = server.name.clone();
let connection = futures::spawn(server.accept()).expect("No connection formed");

Once a server is created, you can then use the server's name to create a client:

let client = Client::new(server_name.clone()).expect("Failed to connect");

At this point, you can send packets to the client:

connection.send(Some(packets)).expect("Failed to send");

or tell the client you are done sending packets:

connection.send(None).expect("Failed to send");

and close the connection:

connection.close();

The client is immediately available for use, and can receive packets using:

let opt_packets = client.receive_packets(size).expect("Failed to receive packets");
if Some(packets) = opt_packets {
    process_packets(packets);
} //else server is closed

Streaming Packets to Client

Once a connection is formed, it can be used with a stream of packets:

let stream_result = packets_stream.transfer_ipc(connection).collect().wait();

Dependencies

~2.3–3MB
~67K SLoC