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 UnsafeUnpin 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.