Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Builder for configuring and running the validation code generator.

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Create a new builder with default settings.

Source

pub fn file_descriptor_set_bytes(self, bytes: Vec<u8>) -> Self

Set the file descriptor set bytes directly.

Source

pub fn file_descriptor_set_path( self, path: impl AsRef<Path>, ) -> Result<Self, Error>

Read the file descriptor set from a file path.

§Errors

Returns an error if the file cannot be read.

Source

pub fn out_dir(self, path: impl Into<PathBuf>) -> Self

Override the output directory (defaults to OUT_DIR env var).

Source

pub fn extern_path( self, proto_path: impl Into<String>, rust_path: impl Into<String>, ) -> Self

Map a proto package path to a Rust module path.

This is equivalent to prost-build’s extern_path and should match your prost-build configuration.

§Example
prost_protovalidate_build::Builder::new()
    .extern_path(".my.package", "::my_crate::my_package");
Source

pub fn compile(self) -> Result<(), Error>

Run the code generator.

§Errors

Returns an error if the descriptor set is missing, cannot be parsed, or the output file cannot be written.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.