diff --git a/Cargo.toml b/Cargo.toml index b0b7a10..9f9bce0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,8 +27,8 @@ clap = "4.0.32" criterion = "0.5.1" derive-where = "1.1.0" derive_builder = "0.20.2" -derive_more = "0.99.17" -downcast-rs = "1.2.0" +derive_more = "2.0.0" +downcast-rs = "2.0.1" dyn-clonable = "0.9.0" env_logger = "0.11.3" ffmpeg-sys-next = { version = "7.0.0", default-features = false } @@ -43,5 +43,5 @@ pkg-config = "0.3.26" proc-macro2 = "1.0" quote = "1.0" syn = "2.0" -thiserror = "1.0.38" +thiserror = "2.0.12" uuid = "1.3" diff --git a/common/Cargo.toml b/common/Cargo.toml index 722b70e..00b9f25 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -16,6 +16,6 @@ exclude.workspace = true [dependencies] bytes = { workspace = true } -derive_more = { workspace = true } +derive_more = { workspace = true, features = ["deref", "deref_mut", "display"] } futures-util = { workspace = true, features = ["io"] } thiserror = { workspace = true } diff --git a/common/src/error.rs b/common/src/error.rs index f0200c8..90c439b 100644 --- a/common/src/error.rs +++ b/common/src/error.rs @@ -40,12 +40,12 @@ pub struct Report { /// A [`Display`]-able indicating there was extra trailing input after parsing. #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "extra unparsed input")] +#[display("extra unparsed input")] pub struct ExtraUnparsedInput; /// A [`Display`]-able indicating an error occurred while parsing a certain type. #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing value of type `{}`", _0)] +#[display("while parsing value of type `{}`", _0)] pub struct WhileParsingType(&'static str); /// A convenience type alias for a [`Result`](std::result::Result) containing an error wrapped by a [`Report`]. @@ -70,7 +70,7 @@ pub struct ReportStack { /// A null error stack which ignores all data attached to it. #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "")] +#[display("")] pub struct NullReportStack; /// A trait for error types which can be used in a [`Report`]. @@ -95,7 +95,7 @@ pub trait ReportableErrorStack: Display { // #[derive(derive_more::Display)] -#[display(fmt = "{message} at {location}")] +#[display("{message} at {location}")] struct ReportEntry { message: Box, location: &'static Location<'static>, diff --git a/mp4san/Cargo.toml b/mp4san/Cargo.toml index 4485371..a46343f 100644 --- a/mp4san/Cargo.toml +++ b/mp4san/Cargo.toml @@ -18,7 +18,7 @@ exclude.workspace = true bytes = { workspace = true } derive-where = { workspace = true } derive_builder = { workspace = true } -derive_more = { workspace = true } +derive_more = { workspace = true, features = ["display", "from"] } downcast-rs = { workspace = true } dyn-clonable = { workspace = true } futures-util = { workspace = true, features = ["io"] } diff --git a/mp4san/src/lib.rs b/mp4san/src/lib.rs index c338972..627d9f5 100644 --- a/mp4san/src/lib.rs +++ b/mp4san/src/lib.rs @@ -143,7 +143,7 @@ pub const COMPATIBLE_BRAND: FourCC = FourCC { value: *b"isom" }; // #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "box data too large: {} > {}", _0, _1)] +#[display("box data too large: {} > {}", _0, _1)] struct BoxDataTooLarge(u64, u64); const MAX_FTYP_SIZE: u64 = 1024; diff --git a/mp4san/src/parse/error.rs b/mp4san/src/parse/error.rs index 7da4322..88256b2 100644 --- a/mp4san/src/parse/error.rs +++ b/mp4san/src/parse/error.rs @@ -77,23 +77,23 @@ pub trait __ParseResultExt: ResultExt + Sized { pub(crate) use self::__ParseResultExt as ParseResultExt; #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "multiple `{}` boxes", _0)] +#[display("multiple `{}` boxes", _0)] pub(crate) struct MultipleBoxes(pub(crate) BoxType); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing `{}` box", _0)] +#[display("while parsing `{}` box", _0)] pub(crate) struct WhileParsingBox(pub(crate) BoxType); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing `{}` box field `{}`", _0, _1)] +#[display("while parsing `{}` box field `{}`", _0, _1)] pub(crate) struct WhileParsingField(pub(crate) BoxType, pub(crate) T); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing `{}` box child `{}`", _0, _1)] +#[display("while parsing `{}` box child `{}`", _0, _1)] pub(crate) struct WhileParsingChild(pub(crate) BoxType, pub(crate) BoxType); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "where `{} = {}`", _0, _1)] +#[display("where `{} = {}`", _0, _1)] pub(crate) struct WhereEq(pub(crate) T, pub(crate) U); impl ReportableError for ParseError { diff --git a/webpsan/Cargo.toml b/webpsan/Cargo.toml index f6476f9..cfdbd8b 100644 --- a/webpsan/Cargo.toml +++ b/webpsan/Cargo.toml @@ -24,7 +24,7 @@ bitflags = { workspace = true } bitstream-io = { workspace = true } bytes = { workspace = true } derive_builder = { workspace = true } -derive_more = { workspace = true } +derive_more = { workspace = true, features = ["display"] } log = { workspace = true } mediasan-common = { path = "../common", version = "=0.5.3" } num-integer = { workspace = true } diff --git a/webpsan/src/lib.rs b/webpsan/src/lib.rs index 44e3f4a..3e3fa21 100644 --- a/webpsan/src/lib.rs +++ b/webpsan/src/lib.rs @@ -72,7 +72,7 @@ trait ReadSkip: Read + Skip {} type DynChunkReader<'a> = ChunkReader; #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "frame dimensions `{_0}`x`{_1}` do not match canvas dimensions `{_2}`x`{_3}`")] +#[display("frame dimensions `{_0}`x`{_1}` do not match canvas dimensions `{_2}`x`{_3}`")] struct FrameDimensionsMismatch(NonZeroU16, NonZeroU16, NonZeroU32, NonZeroU32); // diff --git a/webpsan/src/parse/bitstream.rs b/webpsan/src/parse/bitstream.rs index a97d630..43e657d 100644 --- a/webpsan/src/parse/bitstream.rs +++ b/webpsan/src/parse/bitstream.rs @@ -26,7 +26,7 @@ pub struct CanonicalHuffmanTree { } #[derive(Display)] -#[display(fmt = "invalid lz77 prefix code `{_0}`")] +#[display("invalid lz77 prefix code `{_0}`")] struct InvalidLz77PrefixCode(u16); pub const LZ77_MAX_LEN: u16 = (LZ77_MAX_SYMBOL - 2) >> 1; diff --git a/webpsan/src/parse/error.rs b/webpsan/src/parse/error.rs index 2e1843e..11d1524 100644 --- a/webpsan/src/parse/error.rs +++ b/webpsan/src/parse/error.rs @@ -58,19 +58,19 @@ pub(crate) trait ParseResultExt: ResultExt + Sized { } #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "multiple `{}` chunks", _0)] +#[display("multiple `{}` chunks", _0)] pub(crate) struct MultipleChunks(pub(crate) FourCC); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "expected `{}` chunk", _0)] +#[display("expected `{}` chunk", _0)] pub(crate) struct ExpectedChunk(pub(crate) FourCC); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing `{}` chunk", _0)] +#[display("while parsing `{}` chunk", _0)] pub(crate) struct WhileParsingChunk(pub(crate) FourCC); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing `{}` chunk field `{}`", _0, _1)] +#[display("while parsing `{}` chunk field `{}`", _0, _1)] pub(crate) struct WhileParsingField(pub(crate) FourCC, pub(crate) T); impl ReportableError for ParseError { diff --git a/webpsan/src/parse/lossless.rs b/webpsan/src/parse/lossless.rs index 1f40a3b..58c3206 100644 --- a/webpsan/src/parse/lossless.rs +++ b/webpsan/src/parse/lossless.rs @@ -26,26 +26,26 @@ pub struct LosslessImage { #[derive(Clone, Display, PartialEq, Eq)] enum Transform { - #[display(fmt = "predictor transform: block size {block_size}")] + #[display("predictor transform: block size {block_size}")] Predictor { block_size: u16, _image: EntropyCodedImage }, - #[display(fmt = "color transform: block size {block_size}")] + #[display("color transform: block size {block_size}")] Color { block_size: u16, _image: EntropyCodedImage }, - #[display(fmt = "subtract green transform")] + #[display("subtract green transform")] SubtractGreen, - #[display(fmt = "color indexing transform: {} colors", "image.width")] + #[display("color indexing transform: {} colors", "image.width")] ColorIndexing { image: EntropyCodedImage }, } #[repr(u8)] #[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord)] enum TransformType { - #[display(fmt = "predictor")] + #[display("predictor")] Predictor = 0b00, - #[display(fmt = "color")] + #[display("color")] Color = 0b01, - #[display(fmt = "subtract green")] + #[display("subtract green")] SubtractGreen = 0b10, - #[display(fmt = "color indexing")] + #[display("color indexing")] ColorIndexing = 0b11, } @@ -59,14 +59,14 @@ struct EntropyCodedImage { struct SpatiallyCodedImage; #[derive(Clone, Copy, Debug, Display, PartialEq, Eq)] -#[display(fmt = "distance {dist} length {len}")] +#[display("distance {dist} length {len}")] struct BackReference { dist: NonZeroU32, len: NonZeroU32, } #[derive(Clone, Copy, Debug, Default, Display, PartialEq, Eq)] -#[display(fmt = "({alpha}, {red}, {green}, {blue})")] +#[display("({alpha}, {red}, {green}, {blue})")] struct Color { alpha: u8, red: u8, @@ -81,9 +81,9 @@ struct ColorCache { #[derive(Clone, Display, PartialEq, Eq)] enum MetaPrefixCodes { - #[display(fmt = "single meta prefix code")] + #[display("single meta prefix code")] Single, - #[display(fmt = "multiple meta prefix codes: max code group {max_code_group}, block size {block_size}")] + #[display("multiple meta prefix codes: max code group {max_code_group}, block size {block_size}")] Multiple { block_size: u16, max_code_group: u16, @@ -124,39 +124,39 @@ struct DistancePrefixCode { } #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "out-of-bounds color cache index `{_0}` >= `{_1}`")] +#[display("out-of-bounds color cache index `{_0}` >= `{_1}`")] struct ColorCacheIndexOutOfBounds(u16, u16); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid back-reference distance `{_0}` at pixel `{_1}`")] +#[display("invalid back-reference distance `{_0}` at pixel `{_1}`")] struct InvalidBackRefDistance(NonZeroU32, u32); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid back-reference length `{_0}` at pixel `{_1}` with image length `{_2}`")] +#[display("invalid back-reference length `{_0}` at pixel `{_1}` with image length `{_2}`")] struct InvalidBackRefLength(NonZeroU32, u32, u32); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid code length repetition `{_0}` at `{_1}` with max symbols `{_2}`")] +#[display("invalid code length repetition `{_0}` at `{_1}` with max symbols `{_2}`")] struct InvalidCodeLengthRepetition(u8, usize, u16); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid color cache size `{_0}`")] +#[display("invalid color cache size `{_0}`")] struct InvalidColorCacheSize(u8); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid duplicate {_0} transform")] +#[display("invalid duplicate {_0} transform")] struct InvalidDuplicateTransform(TransformType); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid predictor `{_0}`")] +#[display("invalid predictor `{_0}`")] struct InvalidPredictor(u8); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid symbol count `{_0}` >= `{_1}`")] +#[display("invalid symbol count `{_0}` >= `{_1}`")] struct InvalidSymbolCount(u16, u16); #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "while parsing {_0} transform")] +#[display("while parsing {_0} transform")] struct WhileParsingTransform(TransformType); // diff --git a/webpsan/src/parse/vp8l.rs b/webpsan/src/parse/vp8l.rs index 4da5ada..c3bc923 100644 --- a/webpsan/src/parse/vp8l.rs +++ b/webpsan/src/parse/vp8l.rs @@ -31,7 +31,7 @@ pub struct Vp8lChunk { // #[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "invalid VP8L signature `0x{_0:x}` != `0x{}`", Vp8lChunk::SIGNATURE)] +#[display("invalid VP8L signature `0x{_0:x}` != `0x{}`", Vp8lChunk::SIGNATURE)] struct InvalidSignature(u8); //