Skip to main content

Header

Struct Header 

Source
pub struct Header {
Show 20 fields pub vannila_instrument_count: Option<i8>, pub layer_count: i16, pub song_name: String, pub song_author: String, pub original_song_author: String, pub song_description: String, pub song_tempo: i16, pub auto_saving: bool, pub auto_saving_duration: i8, pub time_signature: i8, pub minutes_spent: i32, pub left_clicks: i32, pub right_clicks: i32, pub noteblocks_added: i32, pub noteblocks_removed: i32, pub imported_file_name: String, pub is_loop: Option<bool>, pub max_loop_count: Option<i8>, pub loop_start_tick: Option<i16>, pub format: NbsFormat, /* private fields */
}
Expand description

The header contains information about the file

Fields§

§vannila_instrument_count: Option<i8>

Amount of default instruments when the song was saved. This is needed to determine at what index custom instruments start. Only avabile in the new format

§layer_count: i16

The last layer with at least one note block in it, or the last layer that has had its name, volume or stereo changed.

§song_name: String

The name of the song.

§song_author: String

The author of the song.

§original_song_author: String

The original author of the song.

§song_description: String

The description of the song.

§song_tempo: i16

The tempo of the song multiplied by 100.

§auto_saving: bool

Whether auto-saving has been enabled. As of NBS version 4 this value is still saved to the file, but no longer used in the program.

§auto_saving_duration: i8

The amount of minutes between each auto-save (if it has been enabled) (1-60). As of NBS version 4 this value is still saved to the file, but no longer used in the program.

§time_signature: i8

The time signature of the song. If this is 3, then the signature is 3/4. Default is 4. This value ranges from 2-8.

§minutes_spent: i32

Amount of minutes spent on the project.

§left_clicks: i32

Amount of times the user has left-clicked.

§right_clicks: i32

Amount of times the user has right-clicked.

§noteblocks_added: i32

Amount of times the user has added a note block.

§noteblocks_removed: i32

The amount of times the user have removed a note block.

§imported_file_name: String

If the song has been imported from a .mid or .schematic file, that file name is stored here (only the name of the file, not the path).

§is_loop: Option<bool>

Whether looping is on or off. Only avabile in the new format.

§max_loop_count: Option<i8>

0 = infinite. Other values mean the amount of times the song loops. Only avabile in the new format.

§loop_start_tick: Option<i16>

Determines which part of the song (in ticks) it loops back to. Only avabile in the new format.

§format: NbsFormat

Not part of the Header.

Implementations§

Source§

impl Header

Source

pub fn new(format: NbsFormat) -> Self

Source

pub fn decode<R>(reader: &mut R) -> Result<Self, NbsError>
where R: ReadStringExt,

Source

pub fn encode<W>( &self, format: NbsFormat, writer: &mut W, ) -> Result<(), NbsError>
where W: WriteStringExt,

Source

pub fn vannila_instrument_count(&self) -> Result<i8, NbsError>

Source

pub fn song_ticks(&self) -> Result<Option<i16>, NbsError>

Returns the song ticks. This method will only return valid results for old versions and version 3 and 4 of the new version.

Source

pub fn song_length(&self) -> Result<Option<Duration>, NbsError>

Returns the song Duration. This method will only return valid results for old versions and version 3 and 4 of the new version.

Trait Implementations§

Source§

impl Debug for Header

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.