pub struct Codegen { /* private fields */ }Expand description
Builder for pure-Rust Protocol Buffers and ttrpc code generation.
Implementations§
Source§impl Codegen
impl Codegen
Sourcepub fn include(&mut self, include: impl AsRef<Path>) -> &mut Self
pub fn include(&mut self, include: impl AsRef<Path>) -> &mut Self
Adds a directory searched for imported .proto files.
Canonical Google well-known type imports are resolved automatically and do not need to be present in an include directory.
Sourcepub fn includes(
&mut self,
includes: impl IntoIterator<Item = impl AsRef<Path>>,
) -> &mut Self
pub fn includes( &mut self, includes: impl IntoIterator<Item = impl AsRef<Path>>, ) -> &mut Self
Adds directories searched for imported .proto files.
Sourcepub fn inputs(
&mut self,
inputs: impl IntoIterator<Item = impl AsRef<Path>>,
) -> &mut Self
pub fn inputs( &mut self, inputs: impl IntoIterator<Item = impl AsRef<Path>>, ) -> &mut Self
Adds .proto files to compile.
Sourcepub fn rust_protobuf(&mut self) -> &mut Self
pub fn rust_protobuf(&mut self) -> &mut Self
Enables generation of rust-protobuf message types alongside ttrpc services.
Sourcepub fn rust_protobuf_customize(
&mut self,
customize: ProtobufCustomize,
) -> &mut Self
pub fn rust_protobuf_customize( &mut self, customize: ProtobufCustomize, ) -> &mut Self
Sets the rust-protobuf code generation options.
Sourcepub fn rust_protobuf_customize_callback(
&mut self,
customize: impl ProtobufCustomizeCallback,
) -> &mut Self
pub fn rust_protobuf_customize_callback( &mut self, customize: impl ProtobufCustomizeCallback, ) -> &mut Self
Sets a callback for per-element rust-protobuf customization.
Sourcepub fn customize(&mut self, customize: Customize) -> &mut Self
pub fn customize(&mut self, customize: Customize) -> &mut Self
Sets ttrpc client and server generation options.
Sourcepub fn run(&mut self) -> Result<()>
pub fn run(&mut self) -> Result<()>
Parses the configured inputs and writes generated Rust files.
This is equivalent to a protoc-based generation step but does not require protoc or
protoc-gen-rust in PATH.
§Errors
Returns an error if an input cannot be read or parsed, imports or types cannot be resolved, or generated service files cannot be written.
§Panics
Panics if rust_protobuf generation is enabled and message generation fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Codegen
impl !Send for Codegen
impl !Sync for Codegen
impl !UnwindSafe for Codegen
impl Freeze for Codegen
impl Unpin for Codegen
impl UnsafeUnpin for Codegen
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
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> ⓘ
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> ⓘ
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