mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 20:04:20 +00:00
virtio: video: Add an Error implementation for TryFromFormatError.
As a convention, error types should always implement Error, so we're doing it here. The traits are manually implemented as opposed to using ThisError; it was simple enough, and using ThisError requires making the error type an enum which makes it more verbose to construct. BUG=None TEST=cargo build --features "video-decoder,ffmpeg" Change-Id: If94926c1b2f14295b29c877c2c70d361b4adee90 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925332 Commit-Queue: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
parent
03fdffb447
commit
244033437e
1 changed files with 12 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
use thiserror::Error as ThisError;
|
||||
|
||||
|
@ -131,6 +132,17 @@ impl TryAsAvFrameExt for GuestResource {
|
|||
#[derive(Debug)]
|
||||
pub struct TryFromFormatError(());
|
||||
|
||||
impl Display for TryFromFormatError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"No matching format to convert between AvPixelFormat and Format"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for TryFromFormatError {}
|
||||
|
||||
impl TryFrom<Format> for AvPixelFormat {
|
||||
type Error = TryFromFormatError;
|
||||
|
||||
|
|
Loading…
Reference in a new issue