Skip to main content

SampleSettingsFile

Struct SampleSettingsFile 

Source
pub struct SampleSettingsFile {
Show 16 fields pub header: [u8; 21], pub datatype_version: u8, pub unknown: u8, pub tempo: u32, pub trim_bar_len: u32, pub loop_bar_len: u32, pub stretch: u32, pub loop_mode: u32, pub gain: u16, pub quantization: u8, pub trim_start: u32, pub trim_end: u32, pub loop_start: u32, pub slices: Slices<Slice>, pub slices_len: u32, pub checksum: u16,
}
Expand description

An Octatrack .ot file a.k.a. a sample settings file contains trim, slice and attribute settings for a sample/slot. Essentially the type is a combination of SlotAttributes and SlotMarkers data, excluding the slot_id, path and slot_type fields from SlotAttributes.

§The Type’s Name

The Octatrack manual specifically refers to

SAVE SAMPLE SETTINGS will save the trim, slice and attribute settings in a separate file and link it to the sample currently being edited.

– page 87.

So this is the settings file for a given sample.

§Missing Default trait

In practice, a SampleSettingsFile is usually paired with an audio file. This library assumes we’re exclusively operating on Octatrack binary data files, that we have no access to any audio sample files. As such, there is no way to know what a “default” implementation of this type would like. So there isn’t one.

Instead of calling default, always create a new instance with SampleSettingsFile::new.

§Converting to other data types

SampleSettingsFiles can be converted to/from SlotMarkers and/or SlotAttributes using the information from the below table

* requires additional arguments

§Trim Bar Length and Loop Bar Length

These fields are not necessary to have a functional SampleSettingsFile. If both of these fields are set to zero, but the BPM/tempo field is populated, then the Octatrack will load the sample using the BPM/tempo field.

To calculate an appropriate value for these two fields we would have to convert from number of samples to number of bars. This calculation requires the sample rate and length of the relevant audio sample file, meaning this library would need access to such audio sample files.

This library assumes we’re exclusively operating on Octatrack binary data files, that we have no access to any audio files.

Therefore, these two fields are always set to zero when using any of the following methods

If you want to set these two values you have to do one of:

  • Calculate the appropriate tempo value for your desired trim_bar_len or loop_bar_len and use that when calling SampleSettingsFile::new or when creating a new struct from scratch (leaving the trim_bar_len and loop_bar_len fields set to zero if creating a struct from scratch).
  • Manually create the SampleSettingsFile from scratch and provide appropriate values for all fields – note that this means manually adding header etc. field values too.

Please note that the trim_bar_len and loop_bar_len fields are NOT set to zero during deserialization. A SampleSettingsFiles should be correctly represented when the file has been generated by the Octatrack itself.

* SampleSettingsFile::from will be able to convert it in the future, but appropriate fields need to be added to the SlotAttributes type first.

§Little-endian systems

The bytes of this type are swapped during decoding on little-endian systems to ensure data is written out correctly.

Fields§

§header: [u8; 21]

Header

§Validation

Use the SampleSettingsFile::check_header method from the HasHeaderField trait.

The SampleSettingsFile::validate method will call SampleSettingsFile::check_header to verify the current instance’s header.

§datatype_version: u8

Datatype’s version ID

§Validation

Use the SampleSettingsFile::check_file_version method from the HasFileVersionField trait.

The SampleSettingsFile::validate method will call SampleSettingsFile::check_file_version to verify the current instance’s version.

§unknown: u8

Unknown data – can sometimes be 1, usually 0.

§tempo: u32

Tempo determines the BPM of sample playback. In this field, the value is always the machine UI’s BPM (human BPM) multiplied by 24.

From page 86 of the Octatrack manual:

ORIGINAL TEMPO displays the calculated BPM of the sample. If it is not correct, it can be changed using the LEVEL knob. This setting will affect the sound of a timestretched sample. For correct results it should be set to match the original BPM of the sample. Altering this setting will alter the TRIM LEN (BARS) and LOOP LEN (BARS) settings.

§Validation

The SampleSettingsFile::validate method checks whether the field’s current value is within appropriate bounds.

Validating this field against the trim_bar_len and/or loop_bar_len fields is outside the scope of this library.

§trim_bar_len: u32

Number of bars for determining the BPM of sample playback. Should be an appropriate value which corresponds to the tempo field.

From page 86 of the Octatrack manual:

TRIM LEN (BARS) shows the length of the sample in bars. Altering this setting will alter the ORIGINAL TEMPO and LOOP LEN (BARS) settings.

§Validation

The SampleSettingsFile::validate method does not check this field for validity.

Validating this field against the trim_bar_len and/or loop_bar_len fields is outside the scope of this library.

§loop_bar_len: u32

Number of bars for determining the BPM of sample playback. Should be an appropriate value which corresponds to the tempo field.

From page 86 of the Octatrack manual:

LOOP LEN (BARS) displays the amount of bars the looped section of the sample consists of. Altering this setting will alter the ORIGINAL TEMPO and TRIM LEN (BARS) settings.

§Validation

The SampleSettingsFile::validate method does not check this field for validity.

Validating this field against the trim_bar_len and/or loop_bar_len fields is outside the scope of this library.

§stretch: u32

Time-stretching algorithm applied to the sample. See TimeStretchMode for suitable choices.

§No enum usage?

TimeStretchMode has a base representation of u8 but a SampleSettingsFile expects a u32 value for this field. As such, we have to convert to u32 values for this field via TimeStretchMode::try_from instead of the relevant variant. While it may be possible to change this in a future version via a custom implementation of Serialize and Deserialize, it is currently out of scope.

Use the SampleSettingsFile::new method to create a new instance with the appropriate enum variant.

§Validation

The SampleSettingsFile::validate method checks whether this field has an appropriate value.

§loop_mode: u32

Loop mode for the sample. See LoopMode for suitable choices.

§No enum usage?

LoopMode has a base representation of u8 but a SampleSettingsFile expects a u32 value for this field. As such, we have to convert to u32 values for this field via LoopMode::try_from instead of the relevant variant. While it may be possible to change this in a future version via a custom implementation of Serialize and Deserialize, it is currently out of scope.

Use the SampleSettingsFile::new method to create a new instance with the appropriate enum variant.

§Validation

The SampleSettingsFile::validate method checks whether this field has an appropriate value.

§gain: u16

Gain of the sample. -24.0 db <= x <= +24 db range in the machine’s UI, with increments of 0.5 db changes. 0 <= x <= 96 range in binary data file.

§Validation

The SampleSettingsFile::validate method checks whether this field has an appropriate value within the Octatrack’s bounds for gain.

§quantization: u8

Trig Quantization mode applied to the sample. See TrigQuantizationMode for suitable choices.

§No enum usage?

TrigQuantizationMode has a base representation of u8 but a SampleSettingsFile expects a u32 value for this field. As such, we have to convert to u32 values for this field via TrigQuantizationMode::try_from instead of the relevant variant. While it may be possible to change this in a future version via a custom implementation of Serialize and Deserialize, it is currently out of scope.

Use the SampleSettingsFile::new method to create a new instance with the appropriate enum variant.

§Validation

The SampleSettingsFile::validate method checks whether this field has an appropriate value.

§trim_start: u32

Where the trim start marker is placed for the sample, measured in bars. Default is 0 (start of sample).

§Validation

The SampleSettingsFile::validate method checks whether this field is less than trim_end

§trim_end: u32

Where the trim end marker is placed for the sample. When the sample is being played in normal mode (i.e. not using slices), the Octatrack will not play samples past this point.

§Validation

The SampleSettingsFile::validate method checks whether this field is greater than trim_start

§loop_start: u32

Start position for any loops. Default is the same as trim start.

A note from the Octatrack manual on loop point/start behaviour:

If a loop point is set, the sample will play from the start point to the end point, then loop from the loop point to the end point

§Validation

The SampleSettingsFile::validate method checks whether this field is within the bounds of trim_start and trim_end values.

§slices: Slices<Slice>

64 length array containing Slices. See the Slice struct for more details. Any empty slice positions should have zero-valued struct fields.

§Validation

The SampleSettingsFile::validate method calls Slice::validate

§slices_len: u32

Number of usable Slices in this sample. Used by the Octatrack to ignore zero-valued Slices in the slices array when loading the sample.

§checksum: u16

Checksum value for the file. For now, this value must be calculated and added to the struct after the struct is created, via SampleSettingsFile::calculate_checksum

§Example

use ot_tools_io::types::{SampleSettingsFile, SlotMarkers};
use ot_tools_io::HasChecksumField;

let mut ss_f = SampleSettingsFile::new(
    SlotMarkers::default(),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
)?;

let checksum = ss_f.calculate_checksum()?;
ss_f.checksum = checksum;

§Validation

Use the SampleSettingsFile::check_checksum method to check the validity of the current checksum value.

Implementations§

Source§

impl SampleSettingsFile

Source

pub fn new<M: AsRef<SlotMarkers>>( markers: M, gain: Option<u16>, tempo: Option<u32>, trim_bar_len: Option<u32>, loop_bar_len: Option<u32>, stretch: Option<TimeStretchMode>, quantization: Option<TrigQuantizationMode>, loop_mode: Option<LoopMode>, ) -> Result<Self, OtToolsIoError>

Create a new SampleSettingsFile

Values like tempo and gain need to be normalized to relevant Octatrack range bounds when using this method.

§Trim Bar Length and Loop Bar Length

If the trim_bar_len and loop_bar_len arguments are not provided then the corresponding field values are set to zero.

When providing these values you should ensure that you have correctly calculated both of these values AND the tempo value. All three are used simultaneously by the Octatrack, and I haven’t spent any time figuring out which one takes priority (I think it’s BPM/tempo, but I cannot confirm yet).

See the relevant documentation here for more information.

use std::array::from_fn;
use ot_tools_io::OtToolsIoError;
use ot_tools_io::types::{Slices, SlotMarkers, SampleSettingsFile};
use ot_tools_io::settings::{
   TrigQuantizationMode,
   LoopMode,
   TimeStretchMode,
};

let marks = SlotMarkers {
    trim_offset: 0,
    trim_end: 100,
    loop_point: 0,
    slices: Slices::default(),
    slice_count: 0,
};
let x = SampleSettingsFile::new(
    marks,
    Some(48),    // -24.0 <-> +24.0 (0 <-> 96)
    Some(2880),  // bpm x 24 (720 <-> 7200)
    None,        // trim_bar_len will be zero, see documentation explainer
    None,        // loop_bar_len will be zero, see documentation explainer
    Some(TimeStretchMode::default()),
    Some(TrigQuantizationMode::default()),
    Some(LoopMode::default()),
)?;
assert_eq!(x.trim_start, 0);
assert_eq!(x.trim_end, 100);
assert_eq!(x.loop_start, 0);
assert_eq!(x.trim_bar_len, 0);
assert_eq!(x.loop_bar_len, 0);
assert_eq!(x.tempo, 2880);
assert_eq!(x.gain, 48);
assert_eq!(x.stretch, 2);  // converted to u32 repr
assert_eq!(x.quantization, 255);  // converted to u32 repr
assert_eq!(x.loop_mode, 0);  // converted to u32 repr
Examples found in repository?
examples/create_sample_settings_file.rs (line 25)
11fn main() -> Result<(), OtToolsIoError> {
12    let outpath = std::env::temp_dir()
13        .join("ot-tools-io")
14        .join("examples")
15        .join("create_sample_settings_file");
16
17    let marks = SlotMarkers {
18        trim_offset: 0,
19        trim_end: 50000,
20        loop_point: 0,
21        slices: Slices::<Slice>::default(),
22        slice_count: 0,
23    };
24
25    let ss_f = SampleSettingsFile::new(marks, None, None, None, None, None, None, None)?;
26
27    create_dir_all(&outpath)?;
28    ss_f.to_data_file(&outpath.join("sample.ot"))?;
29
30    println!("created new settings file at: {outpath:?}");
31
32    Ok(())
33}
Source

pub fn validate(&self) -> Result<(), OtToolsIoError>

Runs a series of validation checks on the field values for an instance of the type.

Will return an appropriate error if a problem is discovered with a field’s value.

Read through the fields on SampleSettingsFile to find out which ones are checked and how they are checked.

§Invalid Gain Example
use ot_tools_io::OtToolsIoError;
use ot_tools_io::types::{SampleSettingsFile, SlotMarkers};
use ot_tools_io::errors::SampleSettingsError;

let ss_f = SampleSettingsFile::new(
    SlotMarkers::default(),
    Some(100),
    None,
    None,
    None,
    None,
    None,
    None
);

assert_eq!(
    ss_f.unwrap_err().to_string(),
    OtToolsIoError::SampleSettings(
        SampleSettingsError::GainOutOfBounds {value: 100}
    ).to_string(),
);
§Invalid Tempo Example
use ot_tools_io::OtToolsIoError;
use ot_tools_io::types::{SampleSettingsFile, SlotMarkers};
use ot_tools_io::errors::SampleSettingsError;

let ss_f = SampleSettingsFile::new(
    SlotMarkers::default(),
    None,
    Some(120),
    None,
    None,
    None,
    None,
    None
);

assert_eq!(
    ss_f.unwrap_err().to_string(),
    OtToolsIoError::SampleSettings(
        SampleSettingsError::TempoOutOfBounds {value: 120}
    ).to_string(),
);
Source

pub fn to_slot_attr( &self, slot_type: SlotType, slot_id: u8, slot_path: Option<PathBuf>, ) -> Result<SlotAttributes, OtToolsIoError>

Create a new SlotAttributes instance from this SampleSettingsFile.

Will validate the slot_id argument depending on the SlotType variant provided to the slot_type argument.

§Valid Example
use ot_tools_io::types::{SlotMarkers, SampleSettingsFile, SlotAttributes, SlotType};
use std::path::PathBuf;

let ss_f = SampleSettingsFile::new(
    SlotMarkers::default(),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
)?;

let attrs = ss_f.to_slot_attr(
    SlotType::Static,
    100,
    Some(PathBuf::from("some/path"))
)?;

assert_eq!(
    attrs,
    SlotAttributes {
        slot_id: 100,
        slot_type: SlotType::Static,
        path: Some(PathBuf::from("some/path")),
        timestrech_mode: TimeStretchMode::default(),
        loop_mode: LoopMode::default(),
        trig_quantization_mode: TrigQuantizationMode::default(),
        gain: 48,
        bpm: 2880,
    }
);
§Error Example
use ot_tools_io::OtToolsIoError;
use ot_tools_io::errors::SampleSettingsError;
use ot_tools_io::types::{SlotMarkers, SampleSettingsFile, SlotAttributes, SlotType};
use std::path::PathBuf;

let ss_f = SampleSettingsFile::new(
    SlotMarkers::default(),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
)?;

let attrs_err = ss_f.to_slot_attr(
    SlotType::Static,
    200,  // bad slot id!
    Some(PathBuf::from("some/path"))
).unwrap_err();

assert_eq!(
    attrs_err.to_string(),
    OtToolsIoError::SampleSettings(
        SampleSettingsError::SlotIdOutOfBounds { id: 200, slot_type: SlotType::Static }
    ).to_string()
);
Source

pub fn timestretch_mode_into_setting( &self, ) -> Result<TimeStretchMode, OtToolsIoError>

Returns the stretch field as a variant of TimeStretchMode.

Essentially calls TimeStretchMode::try_from

Source

pub fn loop_mode_into_setting(&self) -> Result<LoopMode, OtToolsIoError>

Returns the loop_mode field as a variant of LoopMode

Essentially calls LoopMode::try_from

Source

pub fn trig_quantization_into_setting( &self, ) -> Result<TrigQuantizationMode, OtToolsIoError>

Returns the quantization field as a variant of TrigQuantizationMode

Essentially calls TrigQuantizationMode::try_from

Trait Implementations§

Source§

impl AsMut<SampleSettingsFile> for SampleSettingsFile

Source§

fn as_mut(&mut self) -> &mut SampleSettingsFile

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<SampleSettingsFile> for SampleSettingsFile

Source§

fn as_ref(&self) -> &SampleSettingsFile

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl CheckFileIntegrity for SampleSettingsFile

Source§

impl Clone for SampleSettingsFile

Source§

fn clone(&self) -> SampleSettingsFile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SampleSettingsFile

Source§

impl Debug for SampleSettingsFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SampleSettingsFile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for SampleSettingsFile

Source§

impl<A, M> From<(A, M)> for SampleSettingsFile

Source§

fn from(value: (A, M)) -> Self

Converts to this type from the input type.
Source§

impl<A, M> From<ActiveSlot<A, M>> for SampleSettingsFile

Source§

fn from(value: ActiveSlot<A, M>) -> Self

Converts to this type from the input type.
Source§

impl HasChecksumField for SampleSettingsFile

Source§

fn calculate_checksum(&self) -> Result<u16, OtToolsIoError>

Method for calculating the checksum value for types that have a checksum field Read more
Source§

fn update_checksum(&mut self) -> Result<(), OtToolsIoError>

Method for updating the checksum value for types that have a checksum field Read more
Source§

fn check_checksum(&self) -> Result<bool, OtToolsIoError>

Method to verify if checksum is valid in some data type. See this thread. Read more
Source§

impl HasFileVersionField for SampleSettingsFile

Source§

fn check_file_version(&self) -> Result<bool, OtToolsIoError>

Method to verify if the data file version field is valid for the given type. Read more
Source§

impl HasHeaderField for SampleSettingsFile

Source§

fn check_header(&self) -> Result<bool, OtToolsIoError>

Method to verify if header(s) are valid in some data. See this thread. Read more
Source§

impl Hash for SampleSettingsFile

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl OctatrackFileIO for SampleSettingsFile

Source§

fn to_bytes(&self) -> Result<Vec<u8>, OtToolsIoError>

Encodes struct data to binary representation, after some pre-processing.

Before serializing, will:

  1. generate checksum value
  2. swap bytes of values (when current system is little-endian)
Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, OtToolsIoError>

Decode raw bytes of a .ot data file into a new struct, swapping byte values if system is little-endian.

Source§

fn repr(&self, newlines: Option<bool>)
where Self: Debug,

Read type from an Octatrack data file at path Read more
Source§

fn from_data_file(path: &Path) -> Result<Self, OtToolsIoError>

Read type from an Octatrack data file at path Read more
Source§

fn to_data_file(&self, path: &Path) -> Result<(), OtToolsIoError>

Write type to an Octatrack data file at path Read more
Source§

fn from_yaml_file(path: &Path) -> Result<Self, OtToolsIoError>

Read type from a YAML file at path Read more
Source§

fn from_yaml_str(yaml: &str) -> Result<Self, OtToolsIoError>

Read type from YAML string Read more
Source§

fn to_yaml_file(&self, path: &Path) -> Result<(), OtToolsIoError>

Write type to a YAML file at path Read more
Source§

fn to_yaml_string(&self) -> Result<String, OtToolsIoError>

Create YAML string from type Read more
Source§

fn from_json_file(path: &Path) -> Result<Self, OtToolsIoError>

Read type from a JSON file at path
Source§

fn from_json_str(json: &str) -> Result<Self, OtToolsIoError>

Create type from JSON string Read more
Source§

fn to_json_file(&self, path: &Path) -> Result<(), OtToolsIoError>

Write type to a JSON file at path Read more
Source§

fn to_json_string(&self) -> Result<String, OtToolsIoError>

Create JSON string from type Read more
Source§

impl Ord for SampleSettingsFile

Source§

fn cmp(&self, other: &SampleSettingsFile) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SampleSettingsFile

Source§

fn eq(&self, other: &SampleSettingsFile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for SampleSettingsFile

Source§

fn partial_cmp(&self, other: &SampleSettingsFile) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for SampleSettingsFile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SampleSettingsFile

Source§

impl<A, M> TryFrom<Option<ActiveSlot<A, M>>> for SampleSettingsFile

Source§

type Error = OtToolsIoError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Option<ActiveSlot<A, M>>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.