First pass at runtime
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# roto
|
||||
|
||||
Rust protos without the P.
|
||||
Rust protos without the pointers.
|
||||
|
||||
The codegen is different; we don't create data structures.
|
||||
We mark what where each field is, and only read it when asked.
|
||||
@@ -28,7 +28,7 @@ message Hello {
|
||||
fn parse_proto(data: &[u8]) -> Result<String> {
|
||||
// Scans the data, marks where each flag is as an offset
|
||||
// into the proto.
|
||||
let accessor = HelloProto::new(accessor)?;
|
||||
let accessor = HelloProto::new(data)?;
|
||||
// Load the hello world string; returns bytes, not
|
||||
// a Rust string.
|
||||
let hello_world = accessor.hello_world()?;
|
||||
@@ -40,6 +40,16 @@ fn parse_proto(data: &[u8]) -> Result<String> {
|
||||
}
|
||||
```
|
||||
|
||||
### Sample builder usage
|
||||
|
||||
```rust
|
||||
let mut buf = [0u8; 1024];
|
||||
let mut builder = ProtoBuilder::new(&mut buf);
|
||||
builder.write_string(1, "hello world")?;
|
||||
builder.write_int32(2, 42)?;
|
||||
let data = builder.finish()?; // returns the used slice of the buffer
|
||||
```
|
||||
|
||||
### High level design
|
||||
|
||||
The runtime library offers an iterator over the fields in a message, using the protobuf wire format provide
|
||||
|
||||
Reference in New Issue
Block a user