pub struct ComponentDescriptor { /* private fields */ }
Implementations§
Source§impl ComponentDescriptor
impl ComponentDescriptor
Sourcepub fn get_component(&self, name: &str) -> Option<&Schema>
pub fn get_component(&self, name: &str) -> Option<&Schema>
Get a reference to the component named name
, if such exists.
Sourcepub fn get_unpack<'a>(
&'a self,
schema: &'a ComponentOrInlineSchema,
) -> &'a Schema
pub fn get_unpack<'a>( &'a self, schema: &'a ComponentOrInlineSchema, ) -> &'a Schema
Get a reference to the schema of a type.
If schema
is inline, it itself is returned,
otherwise the component is looked up by name and its schema is returned.
§Panics
Panics if schema
refers to a non-existing component.
Sourcepub fn describe_component(
&mut self,
name: &str,
desc: impl FnOnce(&mut ComponentDescriptor) -> Schema,
) -> ComponentOrInlineSchema
pub fn describe_component( &mut self, name: &str, desc: impl FnOnce(&mut ComponentDescriptor) -> Schema, ) -> ComponentOrInlineSchema
Describes a component, iff it isn’t already described.
§Parameters
name
: name of the componentdesc
: descriptor function
§Returns
Reference to the component
§Circular references
To avoid infinite recursion on circular references, a blanket schema is stored under component name first, then the component is described and the schema replaced.
Note that this may cause invalid spec generation if somewhere in such loop there are types that rely on cloned modification of the schema of underlying component.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ComponentDescriptor
impl RefUnwindSafe for ComponentDescriptor
impl Send for ComponentDescriptor
impl Sync for ComponentDescriptor
impl Unpin for ComponentDescriptor
impl UnwindSafe for ComponentDescriptor
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
Mutably borrows from an owned value. Read more