pub struct Structure(/* private fields */);
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()][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 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 example a-structure, array={1, 2, 3}
  • Ranges are inside brackets ([ and ]). For example a-structure, range=[1, 6, 2] 1 being the min value, 6 the maximum and 2 the step. To specify a GST_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_full()][Self::serialize_full()] has been added for that purpose.

Implementations§

source§

impl Structure

source

pub fn builder(name: impl IntoGStr) -> Builder

source

pub fn new_empty(name: impl IntoGStr) -> Structure

Creates a new, empty Structure with the given name.

See gst_structure_set_name() for constraints on the name parameter.

Free-function: gst_structure_free

§name

name of new structure

§Returns

a new, empty Structure

source

pub fn from_iter( name: impl IntoGStr, iter: impl IntoIterator<Item = (impl IntoGStr, SendValue)> ) -> Structure

Methods from Deref<Target = StructureRef>§

source

pub fn as_ptr(&self) -> *const GstStructure

source

pub fn as_mut_ptr(&self) -> *mut GstStructure

source

pub fn get<'a, T: FromValue<'a>>( &'a self, name: impl IntoGStr ) -> Result<T, GetError<<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>>

source

pub fn get_optional<'a, T: FromValue<'a>>( &'a self, name: impl IntoGStr ) -> Result<Option<T>, GetError<<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>>

source

pub fn value( &self, name: impl IntoGStr ) -> Result<&SendValue, GetError<Infallible>>

source

pub fn get_by_quark<'a, T: FromValue<'a>>( &'a self, name: Quark ) -> Result<T, GetError<<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>>

source

pub fn get_optional_by_quark<'a, T: FromValue<'a>>( &'a self, name: Quark ) -> Result<Option<T>, GetError<<<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>>

source

pub fn value_by_quark( &self, name: Quark ) -> Result<&SendValue, GetError<Infallible>>

source

pub fn set(&mut self, name: impl IntoGStr, value: impl Into<Value> + Send)

source

pub fn set_value(&mut self, name: impl IntoGStr, value: SendValue)

source

pub fn set_by_quark(&mut self, name: Quark, value: impl Into<Value> + Send)

source

pub fn set_value_by_quark(&mut self, name: Quark, value: SendValue)

source

pub fn name<'a>(&self) -> &'a GStr

source

pub fn name_quark(&self) -> Quark

source

pub fn set_name(&mut self, name: impl IntoGStr)

source

pub fn has_name(&self, name: &str) -> bool

source

pub fn has_field(&self, field: impl IntoGStr) -> bool

source

pub fn has_field_with_type(&self, field: impl IntoGStr, type_: Type) -> bool

source

pub fn has_field_by_quark(&self, field: Quark) -> bool

source

pub fn has_field_with_type_by_quark(&self, field: Quark, type_: Type) -> bool

source

pub fn remove_field(&mut self, field: impl IntoGStr)

source

pub fn remove_fields(&mut self, fields: impl IntoIterator<Item = impl IntoGStr>)

source

pub fn remove_all_fields(&mut self)

source

pub fn fields(&self) -> FieldIterator<'_>

source

pub fn iter(&self) -> Iter<'_>

source

pub fn nth_field_name<'a>(&self, idx: u32) -> Option<&'a GStr>

source

pub fn n_fields(&self) -> u32

source

pub fn can_intersect(&self, other: &StructureRef) -> bool

source

pub fn intersect(&self, other: &StructureRef) -> Option<Structure>

source

pub fn is_subset(&self, superset: &StructureRef) -> bool

source

pub fn fixate(&mut self)

source

pub fn fixate_field(&mut self, name: impl IntoGStr) -> bool

source

pub fn fixate_field_bool(&mut self, name: impl IntoGStr, target: bool) -> bool

source

pub fn fixate_field_str( &mut self, name: impl IntoGStr, target: impl IntoGStr ) -> bool

source

pub fn fixate_field_nearest_double( &mut self, name: impl IntoGStr, target: f64 ) -> bool

source

pub fn fixate_field_nearest_fraction( &mut self, name: impl IntoGStr, target: impl Into<Fraction> ) -> bool

source

pub fn fixate_field_nearest_int( &mut self, name: impl IntoGStr, target: i32 ) -> bool

source

pub fn serialize(&self, flags: SerializeFlags) -> GString

source

pub fn serialize_strict( &self, flags: SerializeFlags ) -> Result<GString, BoolError>

source

pub fn foreach<F: FnMut(Quark, &Value) -> ControlFlow<()>>( &self, func: F ) -> bool

source

pub fn map_in_place<F: FnMut(Quark, &mut Value) -> ControlFlow<()>>( &mut self, func: F ) -> bool

source

pub fn filter_map_in_place<F: FnMut(Quark, Value) -> Option<Value>>( &mut self, func: F )

Trait Implementations§

source§

impl AsMut<StructureRef> for Structure

source§

fn as_mut(&mut self) -> &mut StructureRef

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<StructureRef> for Structure

source§

fn as_ref(&self) -> &StructureRef

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<StructureRef> for Structure

source§

fn borrow(&self) -> &StructureRef

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<StructureRef> for Structure

source§

fn borrow_mut(&mut self) -> &mut StructureRef

Mutably borrows from an owned value. Read more
source§

impl Clone for Structure

source§

fn clone(&self) -> Self

Returns a copy 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 Debug for Structure

source§

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

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

impl Deref for Structure

§

type Target = StructureRef

The resulting type after dereferencing.
source§

fn deref(&self) -> &StructureRef

Dereferences the value.
source§

impl DerefMut for Structure

source§

fn deref_mut(&mut self) -> &mut StructureRef

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for Structure

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Structure

source§

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

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

impl Drop for Structure

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Extend<Structure> for CapsRef

source§

fn extend<T: IntoIterator<Item = Structure>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl From<Structure> for Caps

source§

fn from(v: Structure) -> Caps

Converts to this type from the input type.
source§

impl From<Structure> for Value

source§

fn from(v: Structure) -> Value

Converts to this type from the input type.
source§

impl FromGlibPtrBorrow<*const GstStructure> for Structure

source§

impl FromGlibPtrBorrow<*mut GstStructure> for Structure

source§

impl FromGlibPtrFull<*const GstStructure> for Structure

source§

impl FromGlibPtrFull<*mut GstStructure> for Structure

source§

unsafe fn from_glib_full(ptr: *mut GstStructure) -> Self

Safety Read more
source§

impl FromGlibPtrNone<*const GstStructure> for Structure

source§

impl FromGlibPtrNone<*mut GstStructure> for Structure

source§

unsafe fn from_glib_none(ptr: *mut GstStructure) -> Self

Safety Read more
source§

impl FromIterator<Structure> for Caps

source§

fn from_iter<T: IntoIterator<Item = Structure>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromStr for Structure

§

type Err = BoolError

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<'a> FromValue<'a> for Structure

§

type Checker = GenericValueTypeOrNoneChecker<Structure>

Value type checker.
source§

unsafe fn from_value(value: &'a Value) -> Self

Get the contained value from a Value. Read more
source§

impl GlibPtrDefault for Structure

source§

impl IntoGlibPtr<*mut GstStructure> for Structure

source§

unsafe fn into_glib_ptr(self) -> *mut GstStructure

Transfer: full.
source§

impl PartialEq<Structure> for StructureRef

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<StructureRef> for Structure

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Structure

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Structure

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl StaticType for Structure

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl<'a> ToGlibPtr<'a, *const GstStructure> for Structure

§

type Storage = PhantomData<&'a Structure>

source§

fn to_glib_none(&'a self) -> Stash<'a, *const GstStructure, Self>

Transfer: none. Read more
source§

fn to_glib_full(&self) -> *const GstStructure

Transfer: full. Read more
source§

fn to_glib_container(&'a self) -> Stash<'a, P, Self>

Transfer: container. Read more
source§

impl<'a> ToGlibPtr<'a, *mut GstStructure> for Structure

§

type Storage = PhantomData<&'a Structure>

source§

fn to_glib_none(&'a self) -> Stash<'a, *mut GstStructure, Self>

Transfer: none. Read more
source§

fn to_glib_full(&self) -> *mut GstStructure

Transfer: full. Read more
source§

fn to_glib_container(&'a self) -> Stash<'a, P, Self>

Transfer: container. Read more
source§

impl<'a> ToGlibPtrMut<'a, *mut GstStructure> for Structure

§

type Storage = PhantomData<&'a mut Structure>

source§

fn to_glib_none_mut(&'a mut self) -> StashMut<'_, *mut GstStructure, Self>

Transfer: none. Read more
source§

impl ToValue for Structure

source§

fn to_value(&self) -> Value

Convert a value to a Value.
source§

fn value_type(&self) -> Type

Returns the type identifier of self. Read more
source§

impl ToValueOptional for Structure

source§

fn to_value_optional(s: Option<&Self>) -> Value

Convert an Option to a Value.
source§

impl ValueType for Structure

§

type Type = Structure

Type to get the Type from. Read more
source§

impl Eq for Structure

source§

impl Send for Structure

source§

impl Sync for Structure

source§

impl TransparentPtrType for Structure

source§

impl ValueTypeOptional for Structure

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(_: *const GList, _: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GList, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GPtrArray, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GPtrArray, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>

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> IntoClosureReturnValue for T
where T: Into<Value>,

source§

impl<T> StaticTypeExt for T
where T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToOwned for T
where T: Clone,

§

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> ToSendValue for T
where T: Send + ToValue + ?Sized,

source§

fn to_send_value(&self) -> SendValue

Returns a SendValue clone of self.
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> TransparentType for T

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,