pub trait Format {
// Required method
fn write(
&mut self,
req: &WriteRequest,
sets: &mut ResultSets<'_>,
) -> Result<Vec<String>>;
// Provided methods
fn options(&self) -> Vec<OptionField> { ... }
fn validate(&self, _options: &Map<String, Value>) -> Vec<String> { ... }
fn validate_template(
&self,
_options: &Map<String, Value>,
_template: &Value,
) -> (Vec<String>, Vec<String>) { ... }
fn unknown_option_hint(&self, _key: &str) -> Option<String> { ... }
}Required Methods§
Sourcefn write(
&mut self,
req: &WriteRequest,
sets: &mut ResultSets<'_>,
) -> Result<Vec<String>>
fn write( &mut self, req: &WriteRequest, sets: &mut ResultSets<'_>, ) -> Result<Vec<String>>
Write every result set to req.path (and siblings, if the format needs several files);
return the files written.
Provided Methods§
Sourcefn options(&self) -> Vec<OptionField>
fn options(&self) -> Vec<OptionField>
The options this format takes: every key of a report’s output: block except format,
destination, template and extension, which core owns.
Sourcefn validate(&self, _options: &Map<String, Value>) -> Vec<String>
fn validate(&self, _options: &Map<String, Value>) -> Vec<String>
Problems the declared Format::options can’t catch, each a sentence naming the key.
Only called on options whose declared types already passed.
Sourcefn validate_template(
&self,
_options: &Map<String, Value>,
_template: &Value,
) -> (Vec<String>, Vec<String>)
fn validate_template( &self, _options: &Map<String, Value>, _template: &Value, ) -> (Vec<String>, Vec<String>)
Problems with the output’s template (validate’s template, sent for the formats core
gives a template context): errors, then warnings. Only called when the options passed.
Sourcefn unknown_option_hint(&self, _key: &str) -> Option<String>
fn unknown_option_hint(&self, _key: &str) -> Option<String>
A hint added to the “unknown option” error for key, for an option this format doesn’t
take but a sibling format does (password on html).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".