#[repr(u8)]pub enum InputSource {
DisplayPort1 = 15,
DisplayPort2 = 16,
Hdmi1 = 17,
Hdmi2 = 18,
UsbC1 = 25,
UsbC2 = 27,
}
Expand description
An input source value.
See also InputSourceRaw
.
Variants§
Implementations§
Source§impl InputSource
impl InputSource
Source§impl InputSource
impl InputSource
Sourcepub fn as_raw(self) -> InputSourceRaw
pub fn as_raw(self) -> InputSourceRaw
Get InputSourceRaw
.
assert_eq!(InputSource::Hdmi1.as_raw(), 17);
Sourcepub fn raw_from_str(input: &str) -> Result<InputSourceRaw>
pub fn raw_from_str(input: &str) -> Result<InputSourceRaw>
Get InputSourceRaw
from a string.
The string is either the name of an InputSource
or a number.
§Examples
// Input strings are either an [`InputSource`] or a number.
assert_eq!(
InputSource::raw_from_str("Hdmi1").unwrap(),
InputSource::Hdmi1.as_raw()
);
assert_eq!(InputSource::raw_from_str("27").unwrap(), 27);
// Undefined string will be an error.
assert!(InputSource::raw_from_str("xyz").is_err());
// The error message should contain the original string.
assert!(
InputSource::raw_from_str("xyz")
.unwrap_err()
.to_string()
.contains("xyz")
);
Sourcepub fn str_from_raw(value: InputSourceRaw) -> String
pub fn str_from_raw(value: InputSourceRaw) -> String
Get a string from InputSourceRaw
.
§Examples
assert_eq!(InputSource::str_from_raw(InputSource::Hdmi1.as_raw()), "Hdmi1");
assert_eq!(InputSource::str_from_raw(17), "Hdmi1");
assert_eq!(InputSource::str_from_raw(255), "255");
Trait Implementations§
Source§impl AsRef<str> for InputSource
impl AsRef<str> for InputSource
Source§impl Clone for InputSource
impl Clone for InputSource
Source§fn clone(&self) -> InputSource
fn clone(&self) -> InputSource
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for InputSource
impl Debug for InputSource
Source§impl FromStr for InputSource
impl FromStr for InputSource
Source§impl PartialEq for InputSource
impl PartialEq for InputSource
Source§impl TryFrom<&str> for InputSource
impl TryFrom<&str> for InputSource
impl Copy for InputSource
impl StructuralPartialEq for InputSource
Auto Trait Implementations§
impl Freeze for InputSource
impl RefUnwindSafe for InputSource
impl Send for InputSource
impl Sync for InputSource
impl Unpin for InputSource
impl UnwindSafe for InputSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more