#[non_exhaustive]pub enum CudaDeviceError {
Discovery {
operation: &'static str,
source: BoxError,
},
Unavailable {
requested: CudaDeviceId,
discovered: Box<[CudaDeviceInfo]>,
},
Initialization {
device: CudaDeviceId,
operation: &'static str,
source: BoxError,
},
}Expand description
Structured failures from CUDA device discovery and initialization.
The error retains only provider-neutral device identities and metadata. It does not expose the concrete CUDA runtime error type behind a source.
§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};
let error = CudaDeviceError::Unavailable {
requested: CudaDeviceId::from_ordinal(1),
discovered: Vec::new().into_boxed_slice(),
};
assert_eq!(error.requested(), Some(CudaDeviceId::from_ordinal(1)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Discovery
Device discovery failed while performing the named operation.
Fields
The requested device was not present in the discovered device list.
Initialization
Device initialization failed while performing the named operation.
Implementations§
Source§impl CudaDeviceError
impl CudaDeviceError
Sourcepub fn operation(&self) -> Option<&'static str>
pub fn operation(&self) -> Option<&'static str>
Return the operation associated with discovery or initialization.
§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};
let error = CudaDeviceError::Unavailable {
requested: CudaDeviceId::from_ordinal(1),
discovered: Vec::new().into_boxed_slice(),
};
assert_eq!(error.operation(), None);Sourcepub fn requested(&self) -> Option<CudaDeviceId>
pub fn requested(&self) -> Option<CudaDeviceId>
Return the requested device for an unavailable-device error.
§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};
let requested = CudaDeviceId::from_ordinal(1);
let error = CudaDeviceError::Unavailable {
requested,
discovered: Vec::new().into_boxed_slice(),
};
assert_eq!(error.requested(), Some(requested));Sourcepub fn discovered(&self) -> Option<&[CudaDeviceInfo]>
pub fn discovered(&self) -> Option<&[CudaDeviceInfo]>
Borrow the devices discovered for an unavailable-device error.
§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};
let error = CudaDeviceError::Unavailable {
requested: CudaDeviceId::from_ordinal(1),
discovered: Vec::new().into_boxed_slice(),
};
assert!(error.discovered().is_some_and(<[_]>::is_empty));Sourcepub fn device(&self) -> Option<CudaDeviceId>
pub fn device(&self) -> Option<CudaDeviceId>
Return the device whose initialization failed.
§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};
let device = CudaDeviceId::from_ordinal(1);
let error = CudaDeviceError::Initialization {
device,
operation: "create_client",
source: Box::new(std::io::Error::other("context failed")),
};
assert_eq!(error.device(), Some(device));Trait Implementations§
Source§impl Debug for CudaDeviceError
impl Debug for CudaDeviceError
Source§impl Display for CudaDeviceError
impl Display for CudaDeviceError
Source§impl Error for CudaDeviceError
impl Error for CudaDeviceError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for CudaDeviceError
impl !UnwindSafe for CudaDeviceError
impl Freeze for CudaDeviceError
impl Send for CudaDeviceError
impl Sync for CudaDeviceError
impl Unpin for CudaDeviceError
impl UnsafeUnpin for CudaDeviceError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more