MocInfo

Struct MocInfo 

Source
pub struct MocInfo { /* private fields */ }
Expand description

A big struct holding an extreme amount of data.

This struct represents all data relating to the mocp --info command and since MoC can omit certain things while outputting some fields can be empty, for example, if the state is MocState::Stopped the rest will be empty, for playing streams the total_time field will be empty and there will only be a current_time field

Implementations§

Source§

impl MocInfo

Source

pub fn state(&self) -> MocState

Get the state from a MocInfo struct, all the other methods that don’t have the parameter called with do the same for other fields aswell.

Source

pub fn with_state(self, with: MocState) -> Self

Builder-style function to compose a MocInfo struct, this and all the other functions that take a with parameter can also be used the same way…

For example:

use moc_rs::common::{MocInfo, MocState};

let mocinfo = MocInfo::default()
    .with_state(MocState::Playing)
    .with_full_title("Wayfinder & Phace - Hymn (-)".into())
    .with_artist("Wayfinder & Phace".into())
    .with_title("Hymn".into())
    .with_album("-".into());

// All other values will be left as default in this case
Source

pub fn file(&self) -> MocSource

Source

pub fn with_file(self, with: MocSource) -> Self

Source

pub fn full_title(&self) -> String

Source

pub fn with_full_title(self, with: String) -> Self

Source

pub fn artist(&self) -> String

Source

pub fn with_artist(self, with: String) -> Self

Source

pub fn title(&self) -> String

Source

pub fn with_title(self, with: String) -> Self

Source

pub fn album(&self) -> String

Source

pub fn with_album(self, with: String) -> Self

Source

pub fn total_time(&self) -> Duration

Source

pub fn with_total_time(self, with: Duration) -> Self

Source

pub fn current_time(&self) -> Duration

Source

pub fn with_current_time(self, with: Duration) -> Self

Source

pub fn bitrate(&self) -> String

Source

pub fn with_bitrate(self, with: String) -> Self

Source

pub fn avg_bitrate(&self) -> String

Source

pub fn with_avg_bitrate(self, with: String) -> Self

Source

pub fn rate(&self) -> String

Source

pub fn with_rate(self, with: String) -> Self

Trait Implementations§

Source§

impl Debug for MocInfo

Source§

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

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

impl Default for MocInfo

Source§

fn default() -> Self

Returns the “default value” for a type. 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.