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§
Sourcefn max_bytes(&self) -> usize
fn max_bytes(&self) -> usize
The largest input PresetFormat::read accepts, in bytes.
Sourcefn read(&self, bytes: &[u8]) -> Result<Box<dyn PresetModel>, FormatError>
fn read(&self, bytes: &[u8]) -> Result<Box<dyn PresetModel>, FormatError>
Sourcefn read_header(&self, bytes: &[u8]) -> Result<Header, FormatError>
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.
Sourcefn write(&self, model: &dyn PresetModel) -> Result<Vec<u8>, FormatError>
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.
Sourcefn absent_means_default(&self, key: &str) -> bool
fn absent_means_default(&self, key: &str) -> bool
Whether a missing key and an explicit default sound the same.
Sourcefn template(&self) -> &dyn TemplateSource
fn template(&self) -> &dyn TemplateSource
Where the template of this synth comes from.
Sourcefn route_sources(&self) -> &'static [&'static str]
fn route_sources(&self) -> &'static [&'static str]
The names a modulation source may take.
Sourcefn default_polarity(&self, source: &str) -> RoutePolarity
fn default_polarity(&self, source: &str) -> RoutePolarity
The polarity of a route whose edit names none.
Sourcefn check_value(&self, key: &str, stored: f64) -> Result<(), FormatError>
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.
Sourcefn scan(
&self,
model: &dyn PresetModel,
edited: &[&str],
) -> Result<Vec<String>, FormatError>
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.
Sourcefn factory_folder(&self) -> &'static [&'static str]
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".