Skip to main content

PropValue

Enum PropValue 

Source
#[non_exhaustive]
pub enum PropValue { Bool(bool), Int(i64), Uint(u64), Double(f64), Fraction(i32, i32), Str(String), Flags(Vec<String>), }
Expand description

A runtime property value. The variants mirror PropKind.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Bool(bool)

§

Int(i64)

§

Uint(u64)

§

Double(f64)

§

Fraction(i32, i32)

(numerator, denominator).

§

Str(String)

§

Flags(Vec<String>)

The nicks of a set-valued property, in the order they were written.

Implementations§

Source§

impl PropValue

Source

pub fn kind(&self) -> PropKind

The PropKind this value holds.

Source

pub fn parse(kind: PropKind, text: &str) -> Result<PropValue, PropError>

Parse a textual value (as it appears in a gst-launch pipeline) for the given PropKind. true/false for bools; n/d for fractions; a bare integer is also accepted as a fraction n/1. The string kind takes the text verbatim.

Source

pub fn as_bool(&self) -> Option<bool>

Borrow the value as bool, if it is one.

Source

pub fn as_int(&self) -> Option<i64>

Borrow the value as i64, if it is an Int.

Source

pub fn as_uint(&self) -> Option<u64>

Borrow the value as u64, if it is a Uint.

Source

pub fn as_double(&self) -> Option<f64>

Borrow the value as f64, if it is a Double.

Source

pub fn as_fraction(&self) -> Option<(i32, i32)>

Borrow the value as a (num, den) fraction, if it is one.

Source

pub fn as_str(&self) -> Option<&str>

Borrow the value as &str, if it is a Str.

Source

pub fn as_flags(&self) -> Option<&[String]>

Borrow the value as the nicks of a Flags set. The parser has already split the a+b text and (when the property declares enum_values) checked every nick, so an element only matches them.

Source

pub fn has_flag(&self, nick: &str) -> bool

Whether a Flags set contains nick. false for any other kind.

Trait Implementations§

Source§

impl Clone for PropValue

Source§

fn clone(&self) -> PropValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PropValue

Source§

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

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

impl PartialEq for PropValue

Source§

fn eq(&self, other: &PropValue) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PropValue

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> 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> ElementBound for T
where T: Send,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.