pub trait DLDataTypeExt: Sized {
// Required methods
fn to_string(&self) -> String;
fn try_from_str(dtype_str: &str) -> Result<Self>;
}
Expand description
Extra methods for DLDataType
Required Methods§
Sourcefn to_string(&self) -> String
fn to_string(&self) -> String
Convert the DLDataType to a string representation
§Returns
A string representation of the data type (e.g., “int32”, “float64”, “bool”)
Sourcefn try_from_str(dtype_str: &str) -> Result<Self>
fn try_from_str(dtype_str: &str) -> Result<Self>
Parse a string representation into a DLDataType
§Arguments
dtype_str
- The string representation of the data type to parse
§Returns
Ok(DLDataType)
- Successfully parsed data typeErr(Error)
- Failed to parse the string
§Examples
use tvm_ffi::{DLDataType, DLDataTypeExt};
let dtype = DLDataType::try_from_str("int32").unwrap();
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.