#[repr(C)]pub struct Wire { /* private fields */ }
Expand description
Wire
is a Chronicle abstraction over binary resources such as Queue.
There are two access patterns depending on user preferences:
- read/write via the ValueIn and ValueOut abstractions
- direct interaction with the underlying
bytes::Bytes
Data written to a Wire
can optionally have an associated field name, which enables content
to be read and written in a flexible format supporting optional fields and/or arbitrary field order.
Example
// writer places three items onto the `Wire`
wire.write("one").int32(1)
.write("two").int32(2)
.write("three").int32(3);
// reader reads only the content it is interested in, in arbitrary order
let three = wire.read("three").int32();
let one = wire.read("one").int32();
assert!(one == 1);
assert!(three == 3);
Implementations§
§impl Wire
impl Wire
pub fn bytes(&self) -> &Bytes
pub fn bytes(&self) -> &Bytes
Get a handle to the message Bytes
for this Wire
Data can then be read or written (depending on the context in which the Wire
is used) using the
methods described in Bytes
Example
let context = appender.writing_document();
let bytes = context.wire().bytes();
bytes.write_string("incomplete longer write");