[−][src]Trait paperclip::v2::Emitter
Emitter
represents the interface for generating the relevant
modules, API object definitions and the associated calls.
Associated Types
type Definition: Schema + Debug
The associated Schema
implementor.
Required methods
fn state(&self) -> &EmitterState
Returns a reference to the underlying state.
Provided methods
fn generate(&self, api: &Api<Self::Definition>) -> Result<(), Error>
Entrypoint for emitter. Given an API spec, generate code inside Rust modules in the configured working directory.
fn def_ns_name<'a>(
&self,
def: &'a Self::Definition
) -> Result<Box<dyn Iterator<Item = String> + 'a>, Error>
&self,
def: &'a Self::Definition
) -> Result<Box<dyn Iterator<Item = String> + 'a>, Error>
Returns an iterator of path components for the given definition.
NOTE: All components are snake_cased (including the definition name).
fn def_name(&self, def: &Self::Definition) -> Result<String, Error>
Returns the CamelCase name for the given definition.
fn def_mod_path(&self, def: &Self::Definition) -> Result<PathBuf, Error>
Returns the module path (from working directory) for the given definition.
NOTE: This doesn't (shouldn't) set any extension to the leaf component.
fn build_def(
&self,
def: &Self::Definition,
define: bool
) -> Result<EmittedUnit, Error>
&self,
def: &Self::Definition,
define: bool
) -> Result<EmittedUnit, Error>
Builds a given definition. Also takes a bool
to specify whether we're
planning to define a Rust type or whether we're reusing an existing type.
NOTE: We resolve type aliases to known types.
Implementors
impl<S: Schema + Debug> Emitter for DefaultEmitter<S>
[src]
type Definition = S
fn state(&self) -> &EmitterState
[src]
fn generate(&self, api: &Api<Self::Definition>) -> Result<(), Error>
[src]
fn def_ns_name<'a>(
&self,
def: &'a Self::Definition
) -> Result<Box<dyn Iterator<Item = String> + 'a>, Error>
[src]
&self,
def: &'a Self::Definition
) -> Result<Box<dyn Iterator<Item = String> + 'a>, Error>
fn def_name(&self, def: &Self::Definition) -> Result<String, Error>
[src]
fn def_mod_path(&self, def: &Self::Definition) -> Result<PathBuf, Error>
[src]
fn build_def(
&self,
def: &Self::Definition,
define: bool
) -> Result<EmittedUnit, Error>
[src]
&self,
def: &Self::Definition,
define: bool
) -> Result<EmittedUnit, Error>