Module extra::flatpipes

Generic communication channels for things that can be represented as, or transformed to and from, byte vectors.

The FlatPort and FlatChan types implement the generic channel and port interface for arbitrary types and transport strategies. It can particularly be used to send and receive serializable types over I/O streams.

FlatPort and FlatChan implement the same comm traits as pipe-based ports and channels.

Example

This example sends boxed integers across tasks using serialization.

let (port, chan) = serial::pipe_stream();

do task::spawn || {
    for i in range(0, 10) {
        chan.send(@i)
    }
}

for i in range(0, 10) {
    assert @i == port.recv()
}

Safety Note

Flat pipes created from io::Readers and io::Writers share the same blocking properties as the underlying stream. Since some implementations block the scheduler thread, so will their pipes.

Modules

bytepipes
flatteners
pod

Constructors for flat pipes that send POD types using memcpy.

serial

Constructors for flat pipes that using serialization-based flattening.

Structs

FlatChan

A FlatChan, consisting of a Flattener that converts values to byte vectors, and a ByteChan that transmits the bytes.

FlatPort

A FlatPort, consisting of a BytePort that receives byte vectors, and an Unflattener that converts the bytes to a value.

Traits

ByteChan

ByteChans are a simple interface for sending bytes

BytePort

BytePorts are a simple interface for receiving a specified number

Flattener

Flatteners present a value as a byte vector

Unflattener

Unflatteners convert a byte vector to a value