Repository navigation
v0.1.0: plain Rust sync and async traits for protobuf services
First release.
Added
-
protoc-gen-contract-rust, a protoc plugin that emits, per protobuf
service:<Service>Sync, whose methods returnResult<Reply, contract::Status>.
It is dyn-compatible:Arc<dyn <Service>Sync>.<Service>Async, whose methods return
impl Future<Output = Result<Reply, Status>> + Send, so implementations
write plainasync fnand generic callers pay no allocation.Dyn<Service>Async, a cloneable handle (new,from_arc) that holds
any<Service>Asyncimplementation behind dynamic dispatch, implements
the trait itself, and implementsDebug.
Requests are taken by value and replies returned owned. Comments in the
.protobecome rustdoc. -
Streaming methods of every kind: server, client, and bidirectional. The
sync form takes and returnscontract::BoxIter<'static, _>, the async
formimpl contract::Stream; items areResult<_, Status>, a reply
stream sits inside the call'sResult, and no stream borrows the
service. -
Bridges between the forms, for every kind of method:
contract::Inline
(a sync implementation's async form, run insidepoll),
contract::Offload(the same on tokio's blocking pool), and
contract::Blocking(an async implementation's sync form).Offload
andBlockingcome with the runtime'stokiofeature.Blockinginside
a current-thread runtime fails withFAILED_PRECONDITIONinstead of
panicking, and every bridge ends a stream after its firstErr. -
Plugin parameters
buffa_module=(crateincluded),extern_path=,
file_per_package, andelement_memory_limit=, as
protoc-gen-connect-rustreads them, plusruntime=for the path of the
runtime crate andgate_tokio_feature[=<name>]to put theOffloadand
Blockingimpls behind a Cargo feature. Message paths are absolute and
matchprotoc-gen-buffa0.9.2. Output is a<stem>.__contract.rsper
proto and a<pkg>.mod.rsstitcher per package for
protoc-gen-buffa-packaging(filter=services), or one
<dotted.pkg>.rsper package withfile_per_package. The output can sit
next toprotoc-gen-connect-rust's, in the same modules. -
The plugin refuses, with a message that names the proto element: a
message type no mapping covers, two methods with one Rust name, a
generated name that another item of the package's module (buffa,
connect-rust, or Contract) already has, and any unknown parameter. -
Runtime crate
contract:Status(code, message,Anydetails; a
mirror ofgoogle.rpc.Status),Code(the 17google.rpc.Codevalues),
BoxFuture,BoxIter,BoxStream,Stream(re-exported from
futures-core),IterStream,Inline, and withtokioChannelStream,
Offload, andBlocking. -
Release binaries of the plugin for Linux, macOS, and Windows on amd64
and arm64, static where the platform allows (macOS links only system
libraries), with their sha256 inchecksums-sha256.txt.