| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 3 | |
| 4 | /// Alias for `Result<T, PageError>` |
| 5 | pub type Resultrust-analyzer cargo ogg_pager 0.7.2 error/Result#<T> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#>; |
| 6 | |
| 7 | /// Errors that can occur while performing `Page` operations |
| 8 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 9 | pub enum PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError# { |
| 10 | /// The reader contains a page with a nonzero version |
| 11 | InvalidVersionrust-analyzer cargo ogg_pager 0.7.2 error/PageError#InvalidVersion#, |
| 12 | /// The reader contains a page with a segment count < 1 |
| 13 | BadSegmentCountrust-analyzer cargo ogg_pager 0.7.2 error/PageError#BadSegmentCount#, |
| 14 | /// The reader contains a page without a magic signature (OggS) |
| 15 | MissingMagicrust-analyzer cargo ogg_pager 0.7.2 error/PageError#MissingMagic#, |
| 16 | /// The reader contains too much data for a single page |
| 17 | TooMuchDatarust-analyzer cargo ogg_pager 0.7.2 error/PageError#TooMuchData#, |
| 18 | /// The reader contains too little data to extract the expected information |
| 19 | NotEnoughDatarust-analyzer cargo ogg_pager 0.7.2 error/PageError#NotEnoughData#, |
| 20 | /// Any std::io::Error |
| 21 | Iorust-analyzer cargo ogg_pager 0.7.2 error/PageError#Io#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#), |
| 22 | } |
| 23 | |
| 24 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError# { |
| 25 | fn fmtrust-analyzer cargo ogg_pager 0.7.2 error/impl#[PageError][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 26 | match self { |
| 27 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::InvalidVersionrust-analyzer cargo ogg_pager 0.7.2 error/PageError#InvalidVersion# => { |
| 28 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Invalid stream structure version (Should always be 0)") |
| 29 | }, |
| 30 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::BadSegmentCountrust-analyzer cargo ogg_pager 0.7.2 error/PageError#BadSegmentCount# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Page has a segment count < 1"), |
| 31 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::MissingMagicrust-analyzer cargo ogg_pager 0.7.2 error/PageError#MissingMagic# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Page is missing a magic signature"), |
| 32 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::TooMuchDatarust-analyzer cargo ogg_pager 0.7.2 error/PageError#TooMuchData# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Too much data was provided"), |
| 33 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::NotEnoughDatarust-analyzer cargo ogg_pager 0.7.2 error/PageError#NotEnoughData# => { |
| 34 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Too little data is available for the expected read") |
| 35 | }, |
| 36 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::Iorust-analyzer cargo ogg_pager 0.7.2 error/PageError#Io#(err) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", err), |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | impl Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError# { |
| 42 | fn sourcerust-analyzer cargo ogg_pager 0.7.2 error/impl#[PageError][Error]source().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&(dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)> { |
| 43 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 44 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::Iorust-analyzer cargo ogg_pager 0.7.2 error/PageError#Io#(ref e) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e), |
| 45 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError# { |
| 51 | fn fromrust-analyzer cargo ogg_pager 0.7.2 error/impl#[PageError][`From<std::io::Error>`]from().(err: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError# { |
| 52 | PageErrorrust-analyzer cargo ogg_pager 0.7.2 error/PageError#::Iorust-analyzer cargo ogg_pager 0.7.2 error/PageError#Io#(err) |
| 53 | } |
| 54 | } |