packet-ipc
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 = new.expect;
let server_name = server.name.clone;
let connection = spawn.expect;
Once a server is created, you can then use the server's name to create a client:
let client = new.expect;
At this point, you can send packets to the client:
connection.send.expect;
or tell the client you are done sending packets:
connection.send.expect;
and close the connection:
connection.close;
The client is immediately available for use, and can receive packets using:
let opt_packets = client.receive_packets.expect;
if Some = opt_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.collect.wait;