Skip to main content

PresetFormat

Trait PresetFormat 

Source
pub trait PresetFormat: Send + Sync {
Show 13 methods // Required methods fn synth(&self) -> Synth; fn extension(&self) -> &'static str; fn max_bytes(&self) -> usize; fn read(&self, bytes: &[u8]) -> Result<Box<dyn PresetModel>, FormatError>; fn read_header(&self, bytes: &[u8]) -> Result<Header, FormatError>; fn write(&self, model: &dyn PresetModel) -> Result<Vec<u8>, FormatError>; fn absent_means_default(&self, key: &str) -> bool; fn template(&self) -> &dyn TemplateSource; fn route_sources(&self) -> &'static [&'static str]; fn default_polarity(&self, source: &str) -> RoutePolarity; fn check_value(&self, key: &str, stored: f64) -> Result<(), FormatError>; fn scan( &self, model: &dyn PresetModel, edited: &[&str], ) -> Result<Vec<String>, FormatError>; fn factory_folder(&self) -> &'static [&'static str];
}
Expand description

The file format of one synth.

Required Methods§

Source

fn synth(&self) -> Synth

The synth the format serves.

Source

fn extension(&self) -> &'static str

The file extension without the dot.

Source

fn max_bytes(&self) -> usize

The largest input PresetFormat::read accepts, in bytes.

Source

fn read(&self, bytes: &[u8]) -> Result<Box<dyn PresetModel>, FormatError>

Decodes a preset.

§Errors

A FormatError naming the key or offset that fails.

Source

fn read_header(&self, bytes: &[u8]) -> Result<Header, FormatError>

Decodes only the header fields, without the large parts.

§Errors

A FormatError as PresetFormat::read gives it.

Source

fn write(&self, model: &dyn PresetModel) -> Result<Vec<u8>, FormatError>

Encodes a model of this synth.

§Errors

A FormatError when the model belongs to another synth, holds a value the format cannot store or lacks a part the synth needs to load the file.

Source

fn absent_means_default(&self, key: &str) -> bool

Whether a missing key and an explicit default sound the same.

Source

fn template(&self) -> &dyn TemplateSource

Where the template of this synth comes from.

Source

fn route_sources(&self) -> &'static [&'static str]

The names a modulation source may take.

Source

fn default_polarity(&self, source: &str) -> RoutePolarity

The polarity of a route whose edit names none.

Source

fn check_value(&self, key: &str, stored: f64) -> Result<(), FormatError>

Checks a stored value that the registry range allows but the writer cannot write yet.

§Errors

A FormatError naming the key, the cause and the fix.

Source

fn scan( &self, model: &dyn PresetModel, edited: &[&str], ) -> Result<Vec<String>, FormatError>

Scans a model after an edit list: every control holds a value of the right wire type inside its range, and the structured parts are whole. Returns warnings, such as a route into a switched-off module.

§Errors

A FormatError for a value the synth would refuse or misread.

Source

fn factory_folder(&self) -> &'static [&'static str]

The trailing folder names of the synth’s factory preset folder, outermost first, such as the data folder and then Factory. The writer refuses to write into it. Empty when the synth has none.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§