Skip to main content

DevEncoded

Struct DevEncoded 

Source
pub struct DevEncoded {
    pub format: Scalar<str>,
    pub data: Spectrum<u8>,
}
Expand description

A value of an encoded attribute or command: octets, and the name of the format they are in, which is how a device sends what Tango has no type for, a compressed image above all. Both share the message they were decoded out of.

Tango only has such a value as a scalar, an attribute of it being neither a spectrum nor an image.

Fields§

§format: Scalar<str>

The name of the format the octets are in, such as JPEG_RGB, which is only a convention between the device and its clients.

§data: Spectrum<u8>

The octets themselves.

Implementations§

Source§

impl DevEncoded

Source

pub fn new( format: impl Into<Scalar<str>>, data: impl Into<Spectrum<u8>>, ) -> Self

An encoded value of that format, out of its octets.

Source§

impl DevEncoded

Source

pub const JPEG_RGB: &'static str = "JPEG_RGB"

The format of a JPEG image in color, see [Self::to_image].

Source

pub const JPEG_GRAY8: &'static str = "JPEG_GRAY8"

The format of a JPEG image in shades of gray, see [Self::to_image].

Source

pub const GRAY8: &'static str = "GRAY8"

The format of raw 8 bits gray pixels, see EncodedPixels::Gray8.

Source

pub const GRAY16: &'static str = "GRAY16"

The format of raw 16 bits gray pixels, see EncodedPixels::Gray16.

Source

pub const RGB24: &'static str = "RGB24"

The format of raw 24 bits color pixels, see EncodedPixels::Rgb24.

Source§

impl DevEncoded

Source

pub fn to_pixels(&self) -> Result<EncodedPixels, Error>

The pixels of an image in one of the raw formats, failing for any other format, JPEG included, see [Self::to_image] for that one.

Source

pub fn from_pixels(pixels: &EncodedPixels) -> Result<Self, Error>

Encode these pixels in their raw format, failing for an image wider or higher than the 65535 pixels its dimensions have room for.

Trait Implementations§

Source§

impl AttrData for DevEncoded

Source§

const DATA_KIND: AttrDataKind = AttrDataKind::Encoded

Source§

const DATA_FORMAT: AttrDataFormat = AttrDataFormat::Scalar

Source§

impl Clone for DevEncoded

Source§

fn clone(&self) -> Self

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 CommandData for DevEncoded

Source§

const DATA_KIND: CommandDataKind = CommandDataKind::Encoded

Source§

impl Debug for DevEncoded

Source§

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

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

impl From<DevEncoded> for Value

Source§

fn from(encoded: DevEncoded) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DevEncoded

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DevEncoded

Source§

impl<'a> TryFrom<&'a Value> for &'a DevEncoded

Source§

type Error = Error

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

fn try_from(data: &'a Value) -> Result<Self, Error>

Performs the conversion.
Source§

impl TryFrom<Value> for DevEncoded

Source§

type Error = Error

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

fn try_from(data: Value) -> Result<Self, Error>

Performs the conversion.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromValue for T
where T: TryFrom<Value>, <T as TryFrom<Value>>::Error: Into<Error>,

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

Source§

impl<T> Model for T
where T: Send + Sync + 'static,

Source§

impl<'name, T> ReadAttrSpec<&'name str> for T
where T: FromValue,

Source§

type Output = AttrRead<T>

The final type of the output.
Source§

fn collect( reads: Vec<Named<Result<AttrRead<Value>, Error>>>, ) -> Result<<T as ReadAttrSpec<&'name str>>::Output, Error>

Build the output out of the readings, one per attribute. Read more
Source§

impl<T> ReadAttrSpec<&Buf<str, 1>> for T
where T: FromValue,

Source§

type Output = Vec<Result<AttrRead<T>, Error>>

The final type of the output.
Source§

fn collect( reads: Vec<Named<Result<AttrRead<Value>, Error>>>, ) -> Result<<T as ReadAttrSpec<&Buf<str, 1>>>::Output, Error>

Build the output out of the readings, one per attribute. Read more
Source§

impl<'name, T> ReadAttrSpec<&[&'name str]> for T
where T: FromValue,

Source§

type Output = Vec<Result<AttrRead<T>, Error>>

The final type of the output.
Source§

fn collect( reads: Vec<Named<Result<AttrRead<Value>, Error>>>, ) -> Result<<T as ReadAttrSpec<&[&'name str]>>::Output, Error>

Build the output out of the readings, one per attribute. Read more
Source§

impl<T> ReadAttrSpec<All> for T
where T: FromValue,

Source§

type Output = Vec<Named<Result<AttrRead<T>, Error>>>

The final type of the output.
Source§

fn collect( reads: Vec<Named<Result<AttrRead<Value>, Error>>>, ) -> Result<<T as ReadAttrSpec<All>>::Output, Error>

Build the output out of the readings, one per attribute. Read more
Source§

impl<T> ReadAttrSpec<Buf<str, 1>> for T
where T: FromValue,

Source§

type Output = Vec<Result<AttrRead<T>, Error>>

The final type of the output.
Source§

fn collect( reads: Vec<Named<Result<AttrRead<Value>, Error>>>, ) -> Result<<T as ReadAttrSpec<Buf<str, 1>>>::Output, Error>

Build the output out of the readings, one per attribute. Read more
Source§

impl<'name, T, const N: usize> ReadAttrSpec<[&'name str; N]> for T
where T: FromValue,

Source§

type Output = [Result<AttrRead<T>, Error>; N]

The final type of the output.
Source§

fn collect( reads: Vec<Named<Result<AttrRead<Value>, Error>>>, ) -> Result<<T as ReadAttrSpec<[&'name str; N]>>::Output, Error>

Build the output out of the readings, one per attribute. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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