Skip to main content

TypeGenerator

Struct TypeGenerator 

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

Type generator that wraps typify’s TypeSpace.

Implementations§

Source§

impl TypeGenerator

Source

pub fn new(spec: &ParsedSpec) -> Result<Self>

Create a new type generator from a parsed spec.

Source

pub fn generate_all_types(&self) -> TokenStream

Generate all types as a TokenStream.

Source

pub fn get_type_name(&self, reference: &str) -> Option<String>

Get the type name for a schema reference.

Source

pub fn type_for_schema( &self, schema: &ReferenceOr<Schema>, name_hint: &str, ) -> TokenStream

Generate a type for an inline schema.

Source

pub fn type_for_boxed_schema( &self, schema: &ReferenceOr<Box<Schema>>, name_hint: &str, ) -> TokenStream

Generate a type for a boxed schema reference.

Source

pub fn path_param_type(&self, param: &OperationParam) -> TokenStream

Get the type for a path parameter.

Source

pub fn query_param_type(&self, param: &OperationParam) -> TokenStream

Get the type for a query parameter.

Source

pub fn request_body_type( &self, body: &RequestBody, op_name: &str, ) -> TokenStream

Get the type for a request body.

Source

pub fn response_type( &self, schema: &Option<ReferenceOr<Schema>>, op_name: &str, status: u16, ) -> TokenStream

Get the type for a response body.

Source

pub fn generate_query_struct( &self, op: &Operation, ) -> Option<(Ident, TokenStream)>

Generate a query params struct for an operation.

Source

pub fn generate_path_type(&self, op: &Operation) -> TokenStream

Generate a path params type for an operation (usually a tuple).

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.