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.
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()
}
Flat pipes created from io::Reader
s and io::Writer
s share the same
blocking properties as the underlying stream. Since some implementations
block the scheduler thread, so will their pipes.
bytepipes | |
flatteners | |
pod | Constructors for flat pipes that send POD types using memcpy. |
serial | Constructors for flat pipes that using serialization-based flattening. |
FlatChan | A FlatChan, consisting of a |
FlatPort | A FlatPort, consisting of a |
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 |
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).