Struct gstreamer::structure::Structure [−][src]
pub struct Structure(_);
A crate::Structure
is a collection of key/value pairs. The keys are expressed as
GQuarks and the values can be of any GType.
In addition to the key/value pairs, a crate::Structure
also has a name. The name
starts with a letter and can be filled by letters, numbers and any of
“/-_.:”.
crate::Structure
is used by various GStreamer subsystems to store information in
a flexible and extensible way. A crate::Structure
does not have a refcount
because it usually is part of a higher level object such as crate::Caps
,
crate::Message
, crate::Event
, crate::Query
. It provides a means to enforce mutability
using the refcount of the parent with the [Self::set_parent_refcount()
]
method.
A crate::Structure
can be created with Self::new_empty()
or
Self::new()
, which both take a name and an optional set of key/value
pairs along with the types of the values.
Field values can be changed with [Self::set_value()
] or
[Self::set()
].
Field values can be retrieved with [Self::get_value()
] or the more
convenient gst_structure_get_*() functions.
Fields can be removed with [Self::remove_field()
] or
[Self::remove_fields()
].
Strings in structures must be ASCII or UTF-8 encoded. Other encodings are not
allowed. Strings may be None
however.
The serialization format
GstStructure serialization format serialize the GstStructure name,
keys/GType/values in a comma separated list with the structure name as first
field without value followed by separated key/value pairs in the form
key=value
, for example:
a-structure, key=value
The values type will be inferred if not explicitly specified with the
(GTypeName)value
syntax, for example the following struct will have one
field called ‘is-string’ which has the string ‘true’ as a value:
a-struct, field-is-string=(string)true, field-is-boolean=true
Note: without specifying (string),
field-is-string` type would have been
inferred as boolean.
Note: we specified (string)
as a type even if gchararray
is the actual
GType name as for convenience some well known types have been aliased or
abbreviated.
To avoid specifying the type, you can give some hints to the “type system”.
For example to specify a value as a double, you should add a decimal (ie. 1
is an int
while 1.0
is a double
).
Note: when a structure is serialized with [Self::to_string
], all
values are explicitly typed.
Some types have special delimiters:
- GstValueArray are inside curly brackets (
{
and}
). For examplea-structure, array={1, 2, 3}
- Ranges are inside brackets (
[
and]
). For examplea-structure, range=[1, 6, 2]
1 being the min value, 6 the maximum and 2 the step. To specify aGST_TYPE_INT64_RANGE
you need to explicitly specify it like:a-structure, a-int64-range=(gint64) [1, 5]
- GstValueList are inside “less and greater than” (
<
and>
). For example `a-structure, list=<1, 2, 3>
Structures are delimited either by a null character \0
or a semicolumn ;
the latter allowing to store multiple structures in the same string (see
#GstCaps).
Quotes are used as “default” delimiters and can be used around any types that
don’t use other delimiters (for example a-struct, i=(int)"1"
). They are use
to allow adding spaces or special characters (such as delimiters,
semicolumns, etc..) inside strings and you can use backslashes \
to escape
characters inside them, for example:
a-struct, special="\"{[(;)]}\" can be used inside quotes"
They also allow for nested structure, such as:
a-struct, nested=(GstStructure)"nested-struct, nested=true"
Note: Be aware that the current #GstCaps / #GstStructure serialization into string has limited support for nested #GstCaps / #GstStructure fields. It can only support one level of nesting. Using more levels will lead to unexpected behavior when using serialization features, such as gst_caps_to_string() or gst_value_serialize() and their counterparts.
Implementations
impl Structure
[src]
impl Structure
[src]pub fn builder(name: &str) -> Builder
[src]
pub fn new_empty(name: &str) -> Structure
[src]
pub fn new_empty(name: &str) -> Structure
[src]Creates a new, empty crate::Structure
with the given name
.
See [Self::set_name()
] for constraints on the name
parameter.
Free-function: gst_structure_free
name
name of new structure
Returns
a new, empty crate::Structure
pub fn new(
name: &str,
values: &[(&str, &(dyn ToSendValue + Sync))]
) -> Structure
[src]
pub fn new(
name: &str,
values: &[(&str, &(dyn ToSendValue + Sync))]
) -> Structure
[src]Creates a new crate::Structure
with the given name. Parses the
list of variable arguments and sets fields to the values listed.
Variable arguments should be passed as field name, field type,
and value. Last variable argument should be None
.
Free-function: gst_structure_free
name
name of new structure
firstfield
name of first field to set
Returns
a new crate::Structure
pub unsafe fn into_ptr(self) -> *mut GstStructure
[src]
pub fn from_iter<'a, 'b, I>(name: &str, iter: I) -> Structure where
I: IntoIterator<Item = (&'a str, &'b SendValue)>,
[src]
I: IntoIterator<Item = (&'a str, &'b SendValue)>,
Methods from Deref<Target = StructureRef>
pub unsafe fn as_ptr(&self) -> *const GstStructure
[src]
pub unsafe fn as_mut_ptr(&self) -> *mut GstStructure
[src]
pub fn get<'a, T: FromValue<'a>>(&'a self, name: &str) -> Result<T, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
[src]
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
pub fn get_optional<'a, T: FromValue<'a>>(
&'a self,
name: &str
) -> Result<Option<T>, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
[src]
&'a self,
name: &str
) -> Result<Option<T>, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
pub fn value(&self, name: &str) -> Result<&SendValue, GetError>
[src]
pub fn get_by_quark<'a, T: FromValue<'a>>(
&'a self,
name: Quark
) -> Result<T, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
[src]
&'a self,
name: Quark
) -> Result<T, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
pub fn get_optional_by_quark<'a, T: FromValue<'a>>(
&'a self,
name: Quark
) -> Result<Option<T>, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
[src]
&'a self,
name: Quark
) -> Result<Option<T>, GetError> where
<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error: GlibValueError,
pub fn value_by_quark(&self, name: Quark) -> Result<&SendValue, GetError>
[src]
pub fn set<T: ToSendValue + Sync>(&mut self, name: &str, value: T)
[src]
pub fn set_value(&mut self, name: &str, value: SendValue)
[src]
pub fn set_by_quark<T: ToSendValue + Sync>(&mut self, name: Quark, value: T)
[src]
pub fn set_value_by_quark(&mut self, name: Quark, value: SendValue)
[src]
pub fn name<'a>(&self) -> &'a str
[src]
pub fn name_quark(&self) -> Quark
[src]
pub fn set_name(&mut self, name: &str)
[src]
pub fn has_field(&self, field: &str) -> bool
[src]
pub fn has_field_with_type(&self, field: &str, type_: Type) -> bool
[src]
pub fn has_field_by_quark(&self, field: Quark) -> bool
[src]
pub fn has_field_with_type_by_quark(&self, field: Quark, type_: Type) -> bool
[src]
pub fn remove_field(&mut self, field: &str)
[src]
pub fn remove_fields(&mut self, fields: &[&str])
[src]
pub fn remove_all_fields(&mut self)
[src]
pub fn fields(&self) -> FieldIterator<'_>ⓘNotable traits for FieldIterator<'a>
impl<'a> Iterator for FieldIterator<'a> type Item = &'static str;
[src]
Notable traits for FieldIterator<'a>
impl<'a> Iterator for FieldIterator<'a> type Item = &'static str;
pub fn iter(&self) -> Iter<'_>ⓘ
[src]
pub fn nth_field_name<'a>(&self, idx: u32) -> Option<&'a str>
[src]
pub fn n_fields(&self) -> u32
[src]
pub fn can_intersect(&self, other: &StructureRef) -> bool
[src]
pub fn intersect(&self, other: &StructureRef) -> Option<Structure>
[src]
pub fn is_subset(&self, superset: &StructureRef) -> bool
[src]
pub fn fixate(&mut self)
[src]
pub fn fixate_field(&mut self, name: &str) -> bool
[src]
pub fn fixate_field_bool(&mut self, name: &str, target: bool) -> bool
[src]
pub fn fixate_field_str(&mut self, name: &str, target: &str) -> bool
[src]
pub fn fixate_field_nearest_double(&mut self, name: &str, target: f64) -> bool
[src]
pub fn fixate_field_nearest_fraction<T: Into<Fraction>>(
&mut self,
name: &str,
target: T
) -> bool
[src]
&mut self,
name: &str,
target: T
) -> bool
pub fn fixate_field_nearest_int(&mut self, name: &str, target: i32) -> bool
[src]
Trait Implementations
impl AsMut<StructureRef> for Structure
[src]
impl AsMut<StructureRef> for Structure
[src]fn as_mut(&mut self) -> &mut StructureRef
[src]
fn as_mut(&mut self) -> &mut StructureRef
[src]Performs the conversion.
impl AsRef<StructureRef> for Structure
[src]
impl AsRef<StructureRef> for Structure
[src]fn as_ref(&self) -> &StructureRef
[src]
fn as_ref(&self) -> &StructureRef
[src]Performs the conversion.
impl Borrow<StructureRef> for Structure
[src]
impl Borrow<StructureRef> for Structure
[src]fn borrow(&self) -> &StructureRef
[src]
fn borrow(&self) -> &StructureRef
[src]Immutably borrows from an owned value. Read more
impl BorrowMut<StructureRef> for Structure
[src]
impl BorrowMut<StructureRef> for Structure
[src]fn borrow_mut(&mut self) -> &mut StructureRef
[src]
fn borrow_mut(&mut self) -> &mut StructureRef
[src]Mutably borrows from an owned value. Read more
impl Deref for Structure
[src]
impl Deref for Structure
[src]type Target = StructureRef
type Target = StructureRef
The resulting type after dereferencing.
fn deref(&self) -> &StructureRef
[src]
fn deref(&self) -> &StructureRef
[src]Dereferences the value.
impl DerefMut for Structure
[src]
impl DerefMut for Structure
[src]fn deref_mut(&mut self) -> &mut StructureRef
[src]
fn deref_mut(&mut self) -> &mut StructureRef
[src]Mutably dereferences the value.
impl<'de> Deserialize<'de> for Structure
[src]
impl<'de> Deserialize<'de> for Structure
[src]fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
[src]
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
[src]Deserialize this value from the given Serde deserializer. Read more
impl FromGlibPtrFull<*const GstStructure> for Structure
[src]
impl FromGlibPtrFull<*const GstStructure> for Structure
[src]unsafe fn from_glib_full(ptr: *const GstStructure) -> Self
[src]
unsafe fn from_glib_full(ptr: *const GstStructure) -> Self
[src]Safety Read more
impl FromGlibPtrFull<*mut GstStructure> for Structure
[src]
impl FromGlibPtrFull<*mut GstStructure> for Structure
[src]unsafe fn from_glib_full(ptr: *mut GstStructure) -> Self
[src]
unsafe fn from_glib_full(ptr: *mut GstStructure) -> Self
[src]Safety Read more
impl FromGlibPtrNone<*const GstStructure> for Structure
[src]
impl FromGlibPtrNone<*const GstStructure> for Structure
[src]unsafe fn from_glib_none(ptr: *const GstStructure) -> Self
[src]
unsafe fn from_glib_none(ptr: *const GstStructure) -> Self
[src]Safety Read more
impl FromGlibPtrNone<*mut GstStructure> for Structure
[src]
impl FromGlibPtrNone<*mut GstStructure> for Structure
[src]unsafe fn from_glib_none(ptr: *mut GstStructure) -> Self
[src]
unsafe fn from_glib_none(ptr: *mut GstStructure) -> Self
[src]Safety Read more
impl<'a> FromValue<'a> for Structure
[src]
impl<'a> FromValue<'a> for Structure
[src]type Checker = GenericValueTypeOrNoneChecker<Self>
type Checker = GenericValueTypeOrNoneChecker<Self>
Value type checker.
unsafe fn from_value(value: &'a Value) -> Self
[src]
unsafe fn from_value(value: &'a Value) -> Self
[src]Get the contained value from a Value
. Read more
impl GlibPtrDefault for Structure
[src]
impl GlibPtrDefault for Structure
[src]impl PartialEq<StructureRef> for Structure
[src]
impl PartialEq<StructureRef> for Structure
[src]impl StaticType for Structure
[src]
impl StaticType for Structure
[src]fn static_type() -> Type
[src]
fn static_type() -> Type
[src]Returns the type identifier of Self
.
impl<'a> ToGlibPtr<'a, *const GstStructure> for Structure
[src]
impl<'a> ToGlibPtr<'a, *const GstStructure> for Structure
[src]type Storage = &'a Self
fn to_glib_none(&'a self) -> Stash<'a, *const GstStructure, Self>
[src]
fn to_glib_none(&'a self) -> Stash<'a, *const GstStructure, Self>
[src]Transfer: none. Read more
fn to_glib_full(&self) -> *const GstStructure
[src]
fn to_glib_full(&self) -> *const GstStructure
[src]Transfer: full. Read more
fn to_glib_container(&'a self) -> Stash<'a, P, Self>
[src]
fn to_glib_container(&'a self) -> Stash<'a, P, Self>
[src]Transfer: container. Read more
impl<'a> ToGlibPtr<'a, *mut GstStructure> for Structure
[src]
impl<'a> ToGlibPtr<'a, *mut GstStructure> for Structure
[src]type Storage = &'a Self
fn to_glib_none(&'a self) -> Stash<'a, *mut GstStructure, Self>
[src]
fn to_glib_none(&'a self) -> Stash<'a, *mut GstStructure, Self>
[src]Transfer: none. Read more
fn to_glib_full(&self) -> *mut GstStructure
[src]
fn to_glib_full(&self) -> *mut GstStructure
[src]Transfer: full. Read more
fn to_glib_container(&'a self) -> Stash<'a, P, Self>
[src]
fn to_glib_container(&'a self) -> Stash<'a, P, Self>
[src]Transfer: container. Read more
impl<'a> ToGlibPtrMut<'a, *mut GstStructure> for Structure
[src]
impl<'a> ToGlibPtrMut<'a, *mut GstStructure> for Structure
[src]impl ToValueOptional for Structure
[src]
impl ToValueOptional for Structure
[src]fn to_value_optional(s: Option<&Self>) -> Value
[src]
fn to_value_optional(s: Option<&Self>) -> Value
[src]Convert an Option
to a Value
.
impl Eq for Structure
[src]
impl Send for Structure
[src]
impl Sync for Structure
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> ToSendValue for T where
T: Send + ToValue + ?Sized,
[src]
impl<T> ToSendValue for T where
T: Send + ToValue + ?Sized,
[src]pub fn to_send_value(&self) -> SendValue
[src]
pub fn to_send_value(&self) -> SendValue
[src]Returns a SendValue
clone of self
.
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,
[src]
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,