pub struct TwirpBuilder { /* private fields */ }Expand description
Builds protobuf bindings for Twirp.
Client and server are not enabled by defaults and must be enabled with the with_client and with_server methods.
Implementations§
Source§impl TwirpBuilder
impl TwirpBuilder
Sourcepub fn from_prost(config: Config) -> Self
pub fn from_prost(config: Config) -> Self
Builder with a custom prost Config.
Sourcepub fn with_client(self) -> Self
pub fn with_client(self) -> Self
Generates code for the Twirp client.
Sourcepub fn with_server(self) -> Self
pub fn with_server(self) -> Self
Generates code for the Twirp server.
Sourcepub fn with_axum_request_extractor(
self,
name: impl Into<String>,
type_name: impl Into<String>,
) -> Self
pub fn with_axum_request_extractor( self, name: impl Into<String>, type_name: impl Into<String>, ) -> Self
Adds an extra parameter to generated server methods that implements axum::FromRequestParts.
For example
message Service {
rpc Test(TestRequest) returns (TestResponse) {}
}Compiled with option .with_axum_request_extractor("headers", "::axum::http::HeaderMap")
will generate the following code allowing to extract the request headers:
ⓘ
trait Service {
async fn test(request: TestRequest, headers: ::axum::http::HeaderMap) -> Result<TestResponse, TwirpError>;
}Note that the parameter type must implement axum::FromRequestParts.
Sourcepub fn with_type_name_domain(self, domain: impl Into<String>) -> Self
pub fn with_type_name_domain(self, domain: impl Into<String>) -> Self
Customizes the type name domain.
By default, ‘type.googleapis.com’ is used.
Trait Implementations§
Source§impl Default for TwirpBuilder
impl Default for TwirpBuilder
Source§fn default() -> TwirpBuilder
fn default() -> TwirpBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TwirpBuilder
impl !RefUnwindSafe for TwirpBuilder
impl !Send for TwirpBuilder
impl !Sync for TwirpBuilder
impl Unpin for TwirpBuilder
impl !UnwindSafe for TwirpBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more