Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cap'n Proto for Rust

License

NotificationsYou must be signed in to change notification settings

capnproto/capnproto-rust

Repository files navigation

Build Status

documentation

For the latest news,see thecapnproto-rust blog.

Introduction

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.

Features

Crates

capnpRuntime library for dealing with Cap'n Proto messages.crates.io
capnpcRust code generatorplugin, including support for hooking into abuild.rs file in acargo build.crates.io
capnp-futuresSupport for asynchronous reading and writing of Cap'n Proto messages.crates.io
capnp-rpcObject-capability remote procedure call system with"level 1" features.crates.io

Examples

addressbook serialization,RPC

Who is using capnproto-rust?

Unimplemented / Future Work

About

Cap'n Proto for Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors84

Languages


[8]ページ先頭

©2009-2025 Movatter.jp