twirp_rs/
lib.rs

1pub mod client;
2pub mod context;
3pub mod error;
4pub mod headers;
5pub mod server;
6
7#[cfg(any(test, feature = "test-support"))]
8pub mod test;
9
10#[doc(hidden)]
11pub mod details;
12
13pub use client::{Client, ClientBuilder, ClientError, Middleware, Next, Result};
14pub use context::Context;
15pub use error::*; // many constructors like `invalid_argument()`
16pub use http::Extensions;
17
18// Re-export this crate's dependencies that users are likely to code against. These can be used to
19// import the exact versions of these libraries `twirp` is built with -- useful if your project is
20// so sprawling that it builds multiple versions of some crates.
21pub use async_trait;
22pub use axum;
23pub use reqwest;
24pub use tower;
25pub use url;
26
27/// Re-export of `axum::Router`, the type that encapsulates a server-side implementation of a Twirp
28/// service.
29pub use axum::Router;
30
31pub(crate) fn serialize_proto_message<T>(m: T) -> Vec<u8>
32where
33    T: prost::Message,
34{
35    let len = m.encoded_len();
36    let mut data = Vec::with_capacity(len);
37    m.encode(&mut data)
38        .expect("can only fail if buffer does not have capacity");
39    assert_eq!(data.len(), len);
40    data
41}