Skip to main content

Sound

Struct Sound 

Source
pub struct Sound<S = String> {
    pub fname: S,
    pub volume: u8,
    pub repeat: AudioRepetition,
    pub priority: u8,
    pub class: Option<S>,
    pub url: Option<S>,
}
Expand description

Sound triggers are WAV format files intended for sound effects.

See MXP specification: <SOUND> and the MSP (Mud Sound Protocol) specification.

§Examples

use mxp::AudioRepetition;

assert_eq!(
    "<SOUND 'weather/rain.wav' V=80 L=3 P=10 T=combat U='http://example.org:5000/sound'>".parse::<mxp::Sound>(),
    Ok(mxp::Sound {
        fname: "weather/rain.wav".into(),
        volume: 80,
        repeat: AudioRepetition::Count(3.try_into().unwrap()),
        priority: 10,
        class: Some("combat".into()),
        url: Some("http://example.org:5000/sound".into()),
    }),
);

Fields§

§fname: S

File name. May contain wildcards. If no extension is specified, “.wav” should be assumed.

§volume: u8

Volume between 0 and 100.

§repeat: AudioRepetition

Repeat behavior.

§priority: u8

This parameter applies when some sound is playing and another request arrives. Then, if new request has higher (but NOT equal) priority than the one that’s currently being played, old sound must be stopped and the new sound starts playing instead. In the case of a tie, the sound that is already playing wins.

§class: Option<S>

Type of sound, e.g. combat, zone, death, clan. Case-insensitive. This parameter was intended to provide a way to group sounds into subfolders within the main sound directory.

§url: Option<S>

Specifies the URL of the sound file. This allows downloading files from the MUD server. Client should always look in local directories first, and only download the file if it’s not available locally.

Implementations§

Source§

impl<S: AsRef<str>> Sound<S>

Source

pub fn is_off(&self) -> bool

Returns true if this command is a <SOUND OFF> command, causing sounds to stop rather than triggering a sound.

Source§

impl<S> Sound<S>

Source

pub fn map_text<T, F>(self, f: F) -> Sound<T>
where F: FnMut(S) -> T,

Applies a type transformation to all text, returning a new struct.

Source§

impl<S: IntoOwnedString> Sound<S>

Source

pub fn into_owned(self) -> Sound<String>

Source§

impl<S: AsRef<str>> Sound<S>

Source

pub fn borrow_text(&self) -> Sound<&str>

Returns a new struct that borrows text from this one.

Trait Implementations§

Source§

impl<S: Clone> Clone for Sound<S>

Source§

fn clone(&self) -> Sound<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for Sound<S>

Source§

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

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

impl<S: Default> Default for Sound<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S: AsRef<str>> Display for Sound<S>

Source§

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

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

impl FromStr for Sound

Source§

type Err = FromStrError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq<Sound<&str>> for Sound<String>

Source§

fn eq(&self, other: &Sound<&str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Sound<&str>> for Sound<Cow<'_, str>>

Source§

fn eq(&self, other: &Sound<&str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Sound<Cow<'_, str>>> for Sound<String>

Source§

fn eq(&self, other: &Sound<Cow<'_, str>>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Sound<Cow<'_, str>>> for Sound<&str>

Source§

fn eq(&self, other: &Sound<Cow<'_, str>>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Sound> for Sound<&str>

Source§

fn eq(&self, other: &Sound<String>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Sound> for Sound<Cow<'_, str>>

Source§

fn eq(&self, other: &Sound<String>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: PartialEq> PartialEq for Sound<S>

Source§

fn eq(&self, other: &Sound<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<&'a str> for Sound<Cow<'a, str>>

Source§

type Error = FromStrError

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

fn try_from(s: &'a str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S: Copy> Copy for Sound<S>

Source§

impl<S: Eq> Eq for Sound<S>

Source§

impl<S> StructuralPartialEq for Sound<S>

Auto Trait Implementations§

§

impl<S> Freeze for Sound<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Sound<S>
where S: RefUnwindSafe,

§

impl<S> Send for Sound<S>
where S: Send,

§

impl<S> Sync for Sound<S>
where S: Sync,

§

impl<S> Unpin for Sound<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Sound<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Sound<S>
where S: UnwindSafe,

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<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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.