- Notifications
You must be signed in to change notification settings - Fork234
capnproto/capnproto-rust
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
For the latest news,see thecapnproto-rust blog.
Cap'n Proto is a type system for distributed systems.
With Cap'n Proto, you describe your data and interfacesin aschema file, like this:
@0x986b3393db1396c9;structPoint { x@0:Float32; y@1:Float32;}interface PointTracker { addPoint@0 (p:Point) -> (totalPoints:UInt64);}
You can then use thecapnp toolto generate code in avariety of programming languages.The generated code lets you produce and consume values of thetypes you've defined in your schema.
Values are encoded ina format thatis suitable not only for transmission over a network and persistence to disk,but also for zero-copy in-memory traversal.That is, you can completely skip serialization and deserialization!It's in this sense that Cap'n Proto is"infinity times faster"than alternatives like Protocol Buffers.
In Rust, the generated code for the example above includesapoint::Reader<'a>
struct withget_x()
andget_y()
methods,and apoint::Builder<'a>
struct withset_x()
andset_y()
methods.The lifetime parameter'a
is a formal reminderthatpoint::Reader<'a>
andpoint::Builder<'a>
contain borrowed references to the raw buffers that contain the encoded messages.Those underlying buffers are never actually copied into separate data structures.
The generated code for the example above also includesapoint_tracker::Server
trait with anadd_point()
method,and apoint_tracker::Client
struct with anadd_point_request()
method.The former can be implemented to create a network-accessible object,and the latter can be used to invoke a possibly-remote instance of aPointTracker
.
- tagged unions
- generics
- protocol evolvability
- canonicalization
Result
-based error handlingno_std
support- no-alloc support
- reflection
capnp | Runtime library for dealing with Cap'n Proto messages. | |
capnpc | Rust code generatorplugin, including support for hooking into abuild.rs file in acargo build. | |
capnp-futures | Support for asynchronous reading and writing of Cap'n Proto messages. | |
capnp-rpc | Object-capability remote procedure call system with"level 1" features. |
- Sandstorm'sraw API example app andcollections app
- juice
- combustion-engine
About
Cap'n Proto for Rust
Resources
License
Uh oh!
There was an error while loading.Please reload this page.