pub trait DeviceSpecExt {
// Required method
fn parse(s: &str) -> Result<DeviceSpec>;
}Expand description
Extension trait for DeviceSpec to add parsing functionality.
This is in the device crate because parsing depends on feature flags and error types that are device-specific.
Required Methods§
Sourcefn parse(s: &str) -> Result<DeviceSpec>
fn parse(s: &str) -> Result<DeviceSpec>
Parse a device string into a DeviceSpec.
Examples:
- “CPU” -> DeviceSpec::Cpu
- “CUDA:0” -> DeviceSpec::Cuda { device_id: 0 }
- “cuda” -> DeviceSpec::Cuda { device_id: 0 } (default to device 0)
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.