Struct midly::Smf

source ·
pub struct Smf<'a> {
    pub header: Header,
    pub tracks: Vec<Track<'a>>,
}
Expand description

Represents a single .mid Standard Midi File. If you’re casually looking to parse a .mid file, this is the type you’re looking for.

This type is only available with the alloc feature enabled. If you’re looking for a fully no_std alternative, see the parse function.

Fields§

§header: Header

The header of this MIDI file, indicating tempo information and track format.

§tracks: Vec<Track<'a>>

A list of tracks within this MIDI file.

Each track consists simply of a list of events (ie. there is no track metadata).

Implementations§

Create a new empty Smf with zero tracks, using the given header.

Parse a .mid Standard Midi File from its raw bytes. If you casually want to parse .mid files, this is the function you’re looking for.

Encodes and writes the file to the given generic writer.

Note that this function requires a midly::io::Write writer, not a std::io::Write writer. This makes it possible to support no_std environments, as well as custom writer errors. If you’re looking to write to a File, see the save method. If you’re looking to write to a std::io::Write writer, see the write_std method.

This function is always available, even in no_std environments.

Encodes and writes the file to the given std::io::Write writer.

This function is similar to the write method, but writes to a std::io::Write writer instead of a midly::io::Write writer.

This function is only available with the std feature enabled.

Encodes and writes the file to the given path.

This function is only available with the std feature enabled.

Remove any lifetimed data from this event to create an Smf with 'static lifetime that can be stored and moved everywhere, solving borrow checker issues.

This method creates a copy of the Smf structure. See the make_static method for an in-place solution.

WARNING: Any bytestrings, including meta messages, SysEx dumps and escape sequences will be replaced by empty bytestrings.

Remove any lifetimed data from this event to create an Smf with 'static lifetime that can be stored and moved everywhere, solving borrow checker issues.

This method consumes the Smf structure, reusing the backing memory.

WARNING: Any bytestrings, including meta messages, SysEx dumps and escape sequences will be replaced by empty bytestrings.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.