typify_impl

Struct TypeSpace

source
pub struct TypeSpace { /* private fields */ }
Expand description

A collection of types.

Implementations§

source§

impl TypeSpace

source

pub fn break_cycles(&mut self, range: Range<u64>)

We need to root out any containment cycles, breaking them by inserting a Box type. Our choice of where to break cycles is more arbitrary than optimal, but is well beyond sufficient.

source§

impl TypeSpace

source

pub fn new(settings: &TypeSpaceSettings) -> Self

Create a new TypeSpace with custom settings

source

pub fn add_ref_types<I, S>(&mut self, type_defs: I) -> Result<()>
where I: IntoIterator<Item = (S, Schema)>, S: AsRef<str>,

Add a collection of types that will be used as references. Regardless of how these types are defined–de novo or built-in–each type will appear in the final output as a struct, enum or newtype. This method may be called multiple times, but collections of references must be self-contained; in other words, a type in one invocation may not refer to a type in another invocation.

source

pub fn add_type(&mut self, schema: &Schema) -> Result<TypeId>

Add a new type and return a type identifier that may be used in function signatures or embedded within other types.

source

pub fn add_type_with_name( &mut self, schema: &Schema, name_hint: Option<String>, ) -> Result<TypeId>

Add a new type with a name hint and return a the components necessary to use the type for various components of a function signature.

source

pub fn add_root_schema(&mut self, schema: RootSchema) -> Result<Option<TypeId>>

Add all the types contained within a RootSchema including any referenced types and the top-level type (if there is one and it has a title).

source

pub fn get_type(&self, type_id: &TypeId) -> Result<Type<'_>>

Get a type given its ID.

source

pub fn uses_chrono(&self) -> bool

Whether the generated code needs chrono crate.

source

pub fn uses_regress(&self) -> bool

Whether the generated code needs regress crate.

source

pub fn uses_serde_json(&self) -> bool

Whether the generated code needs serde_json crate.

source

pub fn uses_uuid(&self) -> bool

Whether the generated code needs uuid crate.

source

pub fn iter_types(&self) -> impl Iterator<Item = Type<'_>>

Iterate over all types including those defined in this TypeSpace and those referred to by those types.

source

pub fn to_stream(&self) -> TokenStream

All code for processed types.

Trait Implementations§

source§

impl Debug for TypeSpace

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TypeSpace

source§

fn default() -> Self

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

impl ToTokens for TypeSpace

source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. 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> Spanned for T
where T: Spanned + ?Sized,

source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
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.