Struct gstreamer::structure::Structure [−][src]
pub struct Structure(_);
Expand description
A 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 Structure
also has a name. The name
starts with a letter and can be filled by letters, numbers and any of
“/-_.:”.
Structure
is used by various GStreamer subsystems to store information in
a flexible and extensible way. A Structure
does not have a refcount
because it usually is part of a higher level object such as Caps
,
Message
, Event
, Query
. It provides a means to enforce mutability
using the refcount of the parent with the gst_structure_set_parent_refcount()
method.
A Structure
can be created with new_empty()
or
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 gst_structure_set_value()
or
gst_structure_set()
.
Field values can be retrieved with gst_structure_get_value()
or the more
convenient gst_structure_get_*() functions.
Fields can be removed with gst_structure_remove_field()
or
gst_structure_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 gst_structure_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 semicolon ;
the latter allowing to store multiple structures in the same string (see
Caps
).
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"
Since 1.20, nested structures and caps can be specified using brackets ([
and ]
), for example:
a-struct, nested=[nested-struct, nested=true]
note: [
to_str()
][Self::to_str()] won’t use that syntax for backward compatibility reason, [serialize()
][Self::serialize()] has been added for that purpose.
Implementations
Creates a new 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 Structure
Methods from Deref<Target = StructureRef>
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]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]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]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]pub fn fields(&self) -> FieldIterator<'_>ⓘNotable traits for FieldIterator<'a>
impl<'a> Iterator for FieldIterator<'a> type Item = &'static str;
[src]Trait Implementations
Performs the conversion.
Performs the conversion.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
type Target = StructureRef
type Target = StructureRef
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Deserialize this value from the given Serde deserializer. Read more
Safety Read more
Safety Read more
Safety Read more
Safety Read more
type Checker = GenericValueTypeOrNoneChecker<Self>
type Checker = GenericValueTypeOrNoneChecker<Self>
Value type checker.
Get the contained value from a Value
. Read more
type GlibType = *mut GstStructure
Returns the type identifier of Self
.
Transfer: none. Read more
Convert an Option
to a Value
.
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,
[src]