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
impl AttributeValue
Sourcepub fn as_string(&self) -> Option<&Bytes>
pub fn as_string(&self) -> Option<&Bytes>
Get string value as raw bytes without UTF-8 validation.
Sourcepub fn as_string_validated(&self) -> Result<&str, Error>
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.
Sourcepub fn into_string(self) -> Option<Bytes>
pub fn into_string(self) -> Option<Bytes>
Extract string value as owned Bytes.
Sourcepub fn as_strings(&self) -> Option<&[Bytes]>
pub fn as_strings(&self) -> Option<&[Bytes]>
Get string array value as raw bytes without UTF-8 validation.
Sourcepub fn as_strings_validated(&self) -> Result<Box<[&str]>, Error>
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.
Sourcepub fn into_strings(self) -> Option<Vec<Bytes>>
pub fn into_strings(self) -> Option<Vec<Bytes>>
Extract string array value as owned Vec<Bytes>.
Sourcepub fn into_floats(self) -> Option<Vec<f32>>
pub fn into_floats(self) -> Option<Vec<f32>>
Extract float vector as owned Vec<f32> if the variant is Floats.
Sourcepub fn into_ints(self) -> Option<Vec<i64>>
pub fn into_ints(self) -> Option<Vec<i64>>
Extract integer vector as owned Vec<i64> if the variant is Ints.
Sourcepub fn into_tensor(self) -> Option<Tensor>
pub fn into_tensor(self) -> Option<Tensor>
Extract tensor as owned Tensor if the variant is Tensor.
Sourcepub fn into_graph(self) -> Option<Graph>
pub fn into_graph(self) -> Option<Graph>
Extract subgraph as owned Graph if the variant is Graph.
Sourcepub fn as_tensors(&self) -> Option<&[Tensor]>
pub fn as_tensors(&self) -> Option<&[Tensor]>
Borrow tensor slice if the variant is Tensors.
Sourcepub fn into_tensors(self) -> Option<Box<[Tensor]>>
pub fn into_tensors(self) -> Option<Box<[Tensor]>>
Extract tensor slice as owned Box<[Tensor]> if the variant is Tensors.
Sourcepub fn into_graphs(self) -> Option<Box<[Graph]>>
pub fn into_graphs(self) -> Option<Box<[Graph]>>
Extract subgraph slice as owned Box<[Graph]> if the variant is Graphs.