#[repr(transparent)]
pub struct PodObjectRef { /* private fields */ }
Expand description

Object pod wrapper, used as param value type in the most cases. Pod value represented by ObjectType enum.

Examples

Parse value manually:

if let BasicType::OBJECT(obj) = pod.downcast().unwrap() {
     if let ObjectType::OBJECT_FORMAT(format) = obj.param_value(ParamType::FORMAT).unwrap() {
         for prop in format {
             if let ObjectFormatType::VIDEO_SIZE(size) = prop.value()? {
                   todo!();
             }
         }
     }
 }

Parse as Info object:

if let Ok(BasicType::OBJECT(object)) = param.downcast() {
    match object.body_type() {
        Type::OBJECT_PROP_INFO => {
            let info = ObjectPropInfoInfo::try_from(object).unwrap();
            println ! ("Prop info: {:?}", info);
        }
        _ => todo!(),
    }
}

Create the Object pod manually:

PodObjectRef::from_id_and_value(
    ParamType::ENUM_FORMAT,
    &ObjectType::OBJECT_ENUM_FORMAT(
        AllocatedPodIterator::from_values(&[
            ObjectEnumFormatType::MEDIA_TYPE(MediaType::AUDIO.to_alloc_pod().as_pod()),
            ObjectEnumFormatType::MEDIA_SUBTYPE(MediaSubType::RAW.to_alloc_pod().as_pod()),
            ObjectEnumFormatType::AUDIO_FORMAT(
            PodEnumValue::from_default(AudioFormat::F32)
                .to_alloc_pod()?
                .as_pod()
                .choice(),
            ),
            ObjectEnumFormatType::AUDIO_CHANNELS(
                PodIntRef::from_primitive(CHANNELS as i32)?.as_pod().into(),
            ),
            ObjectEnumFormatType::AUDIO_RATE(
                PodIntRef::from_primitive(RATE as i32)?.as_pod().into(),
            ),
        ])?
        .iter(),
    ),
)

Build the pod with builder:

ObjectEnumFormatBuilder::default()
    .body_id(ParamType::ENUM_FORMAT.into())
    .media_type(MediaType::VIDEO)
    .media_subtype(MediaSubType::RAW)
    .video_format(ChoiceStructType::ENUM(PodEnumValue::from_default(
        VideoFormat::RGB,
    )))
    .video_size(ChoiceStructType::RANGE(PodRangeValue::new(
        RectangleRef::new(320, 240),
        RectangleRef::new(1, 1),
        RectangleRef::new(4096, 4096),
    )))
    .video_framerate(ChoiceStructType::NONE(FractionRef::new(25, 1)))
    .build()?;

Implementations§

source§

impl PodObjectRef

source

pub fn body_type(&self) -> Type

source

pub fn body_id(&self) -> u32

source

pub fn set_body_id(&mut self, id: u32)

source

pub fn from_id_and_value( id: impl Into<u32>, value: &<&Self as PodValue>::Value ) -> Result<AllocPod<Self>, PodError>

source

pub fn param_value( &self, param_type: ParamType ) -> Result<ObjectType<'_>, PodError>

Can be used to retrieve object value with specified body.id value, because body.id value can be Invalid for some reason.

Trait Implementations§

source§

impl Debug for PodObjectRef

source§

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

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

impl From<PodObjectRef> for spa_pod_object

source§

fn from(value: PodObjectRef) -> Self

Converts to this type from the input type.
source§

impl From<spa_pod_object> for PodObjectRef

source§

fn from(value: spa_pod_object) -> Self

Converts to this type from the input type.
source§

impl<'a> PodValue for &'a PodObjectRef

§

type Value = ObjectType<'a>

source§

fn value(&self) -> Result<Self::Value, PodError>

source§

impl RawWrapper for PodObjectRef

§

type CType = spa_pod_object

External type
source§

fn as_raw_ptr(&self) -> *mut Self::CType

Raw ptr to the external type
source§

fn as_raw(&self) -> &Self::CType

Wrapped external value
source§

fn from_raw(raw: Self::CType) -> Self

Creates wrapper from the external value, can be use when external type has no raw pointers.
source§

unsafe fn mut_from_raw_ptr<'lft>(raw: *mut Self::CType) -> &'lft mut Self

Cast external pointer to the borrowed mutable wrapper. Panic when pointer is null. Lifetime is not reliable and should be guaranteed explicitly. Read more
source§

unsafe fn from_raw_ptr<'a>(raw: *const Self::CType) -> &'a Self

Cast external pointer to the borrowed wrapper. Panic when pointer is null. Lifetime is not reliable and should be guaranteed explicitly. Read more
source§

fn as_ptr(&self) -> *mut Self

Raw mutable pointer to Self
source§

impl<'a> TryFrom<&'a PodObjectRef> for ObjectEnumFormatInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ObjectFormatInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ObjectPropInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ObjectPropInfoInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamBuffersInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamIOInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamLatencyInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamMetaInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamPortConfigInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamProcessLatencyInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamProfileInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ParamRouteInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a PodObjectRef> for ProfilerInfo<'a>

§

type Error = PodError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a PodObjectRef) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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<'a, T> FromValue<'a> for Twhere T: 'a, &'a T: WritePod,

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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, U> TryInto<U> for Twhere 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.