Skip to main content

Pmt

Enum Pmt 

Source
#[non_exhaustive]
pub enum Pmt {
Show 19 variants Ok, InvalidValue, Null, String(String), Bool(bool), Usize(usize), Isize(isize), U32(u32), U64(u64), F32(f32), F64(f64), VecCF32(Vec<Complex<f32>>), VecF32(Vec<f32>), VecU64(Vec<u64>), Blob(Vec<u8>), VecPmt(Vec<Pmt>), Finished, MapStrPmt(HashMap<String, Pmt>), Any(Box<dyn PmtAny>),
}
Expand description

Polymorphic message type used by FutureSDR message ports.

PMTs are the input and output values for message handlers and runtime control calls. Most variants serialize normally; Pmt::Any is skipped during serialization and is intended only for in-process values.

String parsing accepts a few short forms such as Ok, Null, true, and false, plus serde-compatible enum JSON such as { "U32": 123 } and the compact U32: 123 syntax used by simple UIs.

use futuresdr_types::{Pmt, PmtKind};

let pmt = Pmt::Usize(7);
assert_eq!(pmt.kind(), PmtKind::Usize);
assert_eq!(usize::try_from(pmt)?, 7);

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

Ok

Successful operation without additional payload.

§

InvalidValue

Invalid value.

Mainly used as the return type in message handlers when the parameter is outside the allowed range.

§

Null

Absence of a value.

Used, for example, as the input type, when the message handler is mainly about the return type.

§

String(String)

UTF-8 string.

§

Bool(bool)

Boolean.

§

Usize(usize)

Native-sized unsigned integer.

§

Isize(isize)

Native-sized signed integer.

§

U32(u32)

32-bit unsigned integer.

§

U64(u64)

64-bit unsigned integer.

§

F32(f32)

32-bit float.

§

F64(f64)

64-bit float.

§

VecCF32(Vec<Complex<f32>>)

Vector of 32-bit complex floats.

§

VecF32(Vec<f32>)

Vector of 32-bit floats.

§

VecU64(Vec<u64>)

Vector of 64-bit unsigned integers.

§

Blob(Vec<u8>)

Binary data blob.

§

VecPmt(Vec<Pmt>)

Vector of PMT values.

§

Finished

Runtime message used to signal that a connected block finished.

§

MapStrPmt(HashMap<String, Pmt>)

Map from string keys to PMT values.

§

Any(Box<dyn PmtAny>)

Type-erased in-process payload.

Wrap anything that implements Any in a Pmt. Use downcast_ref/mut() to extract.

Implementations§

Source§

impl Pmt

Source

pub fn kind(&self) -> PmtKind

Get the PMT variant kind without associated data.

Source§

impl Pmt

Source

pub fn from_string(s: &str, t: &PmtKind) -> Option<Pmt>

Create a Pmt by parsing a string into a specific PmtKind.

Only scalar kinds that have a straightforward textual representation are supported here. Use std::str::FromStr for full PMT JSON parsing.

Trait Implementations§

Source§

impl Clone for Pmt

Source§

fn clone(&self) -> Pmt

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 Pmt

Source§

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

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

impl<'de> Deserialize<'de> for Pmt

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Pmt, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl Display for Pmt

Source§

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

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

impl From<&Pmt> for PmtKind

Source§

fn from(value: &Pmt) -> PmtKind

Converts to this type from the input type.
Source§

impl From<()> for Pmt

Source§

fn from(_: ()) -> Pmt

Converts to this type from the input type.
Source§

impl From<Pmt> for PmtKind

Source§

fn from(value: Pmt) -> PmtKind

Converts to this type from the input type.
Source§

impl From<Vec<Complex<f32>>> for Pmt

Source§

fn from(v: Vec<Complex<f32>>) -> Pmt

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for Pmt

Source§

fn from(v: Vec<f32>) -> Pmt

Converts to this type from the input type.
Source§

impl From<Vec<u64>> for Pmt

Source§

fn from(v: Vec<u64>) -> Pmt

Converts to this type from the input type.
Source§

impl From<bool> for Pmt

Source§

fn from(b: bool) -> Pmt

Converts to this type from the input type.
Source§

impl From<f32> for Pmt

Source§

fn from(f: f32) -> Pmt

Converts to this type from the input type.
Source§

impl From<f64> for Pmt

Source§

fn from(f: f64) -> Pmt

Converts to this type from the input type.
Source§

impl From<isize> for Pmt

Source§

fn from(f: isize) -> Pmt

Converts to this type from the input type.
Source§

impl From<u32> for Pmt

Source§

fn from(f: u32) -> Pmt

Converts to this type from the input type.
Source§

impl From<u64> for Pmt

Source§

fn from(f: u64) -> Pmt

Converts to this type from the input type.
Source§

impl From<usize> for Pmt

Source§

fn from(f: usize) -> Pmt

Converts to this type from the input type.
Source§

impl FromStr for Pmt

Source§

type Err = PmtConversionError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Pmt, <Pmt as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Pmt

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Pmt

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

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

impl TryFrom<Pmt> for Vec<Complex<f32>>

Source§

type Error = PmtConversionError

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

fn try_from( value: Pmt, ) -> Result<Vec<Complex<f32>>, <Vec<Complex<f32>> as TryFrom<Pmt>>::Error>

Performs the conversion.
Source§

impl TryFrom<Pmt> for Vec<f32>

Source§

type Error = PmtConversionError

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

fn try_from(value: Pmt) -> Result<Vec<f32>, <Vec<f32> as TryFrom<Pmt>>::Error>

Performs the conversion.
Source§

impl TryFrom<Pmt> for Vec<u64>

Source§

type Error = PmtConversionError

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

fn try_from(value: Pmt) -> Result<Vec<u64>, <Vec<u64> as TryFrom<Pmt>>::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Pmt

§

impl !RefUnwindSafe for Pmt

§

impl Send for Pmt

§

impl Sync for Pmt

§

impl Unpin for Pmt

§

impl UnsafeUnpin for Pmt

§

impl !UnwindSafe for Pmt

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,