pub struct TypeSpace { /* private fields */ }
Expand description
A collection of types.
Implementations§
source§impl TypeSpace
impl TypeSpace
sourcepub fn break_cycles(&mut self, range: Range<u64>)
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
impl TypeSpace
sourcepub fn new(settings: &TypeSpaceSettings) -> Self
pub fn new(settings: &TypeSpaceSettings) -> Self
Create a new TypeSpace with custom settings
sourcepub fn add_ref_types<I, S>(&mut self, type_defs: I) -> Result<()>
pub fn add_ref_types<I, S>(&mut self, type_defs: I) -> Result<()>
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.
sourcepub fn add_type(&mut self, schema: &Schema) -> Result<TypeId>
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.
sourcepub fn add_type_with_name(
&mut self,
schema: &Schema,
name_hint: Option<String>,
) -> Result<TypeId>
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.
sourcepub fn add_root_schema(&mut self, schema: RootSchema) -> Result<Option<TypeId>>
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).
sourcepub fn uses_chrono(&self) -> bool
pub fn uses_chrono(&self) -> bool
Whether the generated code needs chrono
crate.
sourcepub fn uses_regress(&self) -> bool
pub fn uses_regress(&self) -> bool
Whether the generated code needs regress crate.
sourcepub fn uses_serde_json(&self) -> bool
pub fn uses_serde_json(&self) -> bool
Whether the generated code needs serde_json crate.
sourcepub fn iter_types(&self) -> impl Iterator<Item = Type<'_>>
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.
sourcepub fn to_stream(&self) -> TokenStream
pub fn to_stream(&self) -> TokenStream
All code for processed types.
Trait Implementations§
source§impl ToTokens for TypeSpace
impl ToTokens for TypeSpace
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for TypeSpace
impl RefUnwindSafe for TypeSpace
impl Send for TypeSpace
impl Sync for TypeSpace
impl Unpin for TypeSpace
impl UnwindSafe for TypeSpace
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> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
source§fn span(&self) -> Span
fn span(&self) -> Span
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.