Skip to main content

AttributeValue

Enum AttributeValue 

Source
pub enum AttributeValue {
    Float(f32),
    Int(i64),
    String(Bytes),
    Tensor(Box<Tensor>),
    Graph(Box<Graph>),
    Floats(Vec<f32>),
    Ints(Vec<i64>),
    Strings(Vec<Bytes>),
    Tensors(Box<[Tensor]>),
    Graphs(Box<[Graph]>),
}
Expand description

ONNX attribute values

Variants§

§

Float(f32)

§

Int(i64)

§

String(Bytes)

§

Tensor(Box<Tensor>)

§

Graph(Box<Graph>)

§

Floats(Vec<f32>)

§

Ints(Vec<i64>)

§

Strings(Vec<Bytes>)

§

Tensors(Box<[Tensor]>)

§

Graphs(Box<[Graph]>)

Implementations§

Source§

impl AttributeValue

Source

pub fn as_string(&self) -> Option<&Bytes>

Get string value as raw bytes without UTF-8 validation.

Source

pub fn as_string_validated(&self) -> Result<&str, Error>

Get string value as a validated UTF-8 &str.

Returns Err if the variant is not String or if the bytes are not valid UTF-8. The returned &str borrows directly from the underlying buffer with no copy.

Source

pub fn into_string(self) -> Option<Bytes>

Extract string value as owned Bytes.

Source

pub fn as_strings(&self) -> Option<&[Bytes]>

Get string array value as raw bytes without UTF-8 validation.

Source

pub fn as_strings_validated(&self) -> Result<Box<[&str]>, Error>

Get string array value as validated &str entries.

Returns Err if the variant is not Strings or if any entry is not valid UTF-8. Each &str borrows directly from the underlying buffer with no copy, but the returned Box<[&str]> is a new allocation for the pointer array.

Source

pub fn into_strings(self) -> Option<Vec<Bytes>>

Extract string array value as owned Vec<Bytes>.

Source

pub fn as_float(&self) -> Option<f32>

Get float value if the variant is Float.

Source

pub fn as_int(&self) -> Option<i64>

Get integer value if the variant is Int.

Source

pub fn as_floats(&self) -> Option<&[f32]>

Borrow float slice if the variant is Floats.

Source

pub fn into_floats(self) -> Option<Vec<f32>>

Extract float vector as owned Vec<f32> if the variant is Floats.

Source

pub fn as_ints(&self) -> Option<&[i64]>

Borrow integer slice if the variant is Ints.

Source

pub fn into_ints(self) -> Option<Vec<i64>>

Extract integer vector as owned Vec<i64> if the variant is Ints.

Source

pub fn as_tensor(&self) -> Option<&Tensor>

Borrow tensor if the variant is Tensor.

Source

pub fn into_tensor(self) -> Option<Tensor>

Extract tensor as owned Tensor if the variant is Tensor.

Source

pub fn as_graph(&self) -> Option<&Graph>

Borrow subgraph if the variant is Graph.

Source

pub fn into_graph(self) -> Option<Graph>

Extract subgraph as owned Graph if the variant is Graph.

Source

pub fn as_tensors(&self) -> Option<&[Tensor]>

Borrow tensor slice if the variant is Tensors.

Source

pub fn into_tensors(self) -> Option<Box<[Tensor]>>

Extract tensor slice as owned Box<[Tensor]> if the variant is Tensors.

Source

pub fn as_graphs(&self) -> Option<&[Graph]>

Borrow subgraph slice if the variant is Graphs.

Source

pub fn into_graphs(self) -> Option<Box<[Graph]>>

Extract subgraph slice as owned Box<[Graph]> if the variant is Graphs.

Trait Implementations§

Source§

impl Debug for AttributeValue

Source§

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

Formats the value using the given formatter. Read more

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