Skip to main content

PpuSnapshotError

Enum PpuSnapshotError 

Source
#[non_exhaustive]
pub enum PpuSnapshotError { Truncated(usize), TrailingBytes { consumed: usize, extra: usize, }, UnsupportedVersion(u8), InvalidRegion(u8), InvalidPresence(u8), InvalidOam2FetchAddr(u8), InvalidSprCount(u8), FieldOutOfRange { field: &'static str, value: u8, max: u8, }, InvalidRasterPosition { dot: u16, scanline: i16, }, }
Expand description

Errors returned by Ppu::restore.

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.
§

Truncated(usize)

Blob is too short for the version-1 schema.

§

TrailingBytes

The blob decoded completely with bytes left over (v2.9.9, NC-14: this used to be reported as Truncated at the end offset).

Fields

§consumed: usize

Bytes the schema consumed.

§extra: usize

Bytes left over.

§

UnsupportedVersion(u8)

The blob’s version byte is not understood by this build.

§

InvalidRegion(u8)

Region tag was not one of 0 (NTSC), 1 (PAL), 2 (Dendy).

§

InvalidPresence(u8)

Optional struct presence byte was something other than 0 or 1.

§

InvalidOam2FetchAddr(u8)

v9 OAM2 fetch address was outside the 5-bit hardware counter’s range.

oam2_fetch_addr indexes the 32-byte secondary-OAM bus, and the hardware counter it models is 5 bits wide, so anything >= 32 is a corrupt or hostile blob rather than a state this emulator can reach. Rejected at the boundary instead of masked, so a malformed file is reported rather than silently reinterpreted as a different state.

§

InvalidSprCount(u8)

The in-range sprite count exceeded the eight sprites secondary OAM holds.

spr_count bounds loops over the eight-slot sprite arrays (spr_x, spr_halted, the shift registers), so a value above 8 would restore without complaint and then index out of bounds on the next PPU dot – a deferred panic, and on a panic = "abort" release build a process kill from a hand-edited save. Core audit IMP-01.

§

FieldOutOfRange

A counter or index held a value the PPU never produces.

Each of these is incremented without a mask or used as an index, so a value past its range overflows or indexes out of bounds on a later dot. The limits are the ranges the running PPU keeps them in (fine X is the 3-bit x register; the sprite-evaluation and OAM-bus counters are reset at their wrap points). Found field by field by the v2.7.0 save_state fuzz target (fine X: ppu.rs:4788, shift overflow, in 92,496 runs) and then swept for the rest rather than left to the fuzzer one run at a time.

Fields

§field: &'static str

Which field.

§value: u8

The value found in the blob.

§max: u8

The largest value the PPU keeps it at.

§

InvalidRasterPosition

The raster position is outside the region’s frame.

dot runs 0..=340 and scanline -1..=the region’s pre-render line (-1 is the power-on position). The per-dot advance only wraps at exactly those limits, so a position past either counts on until the integer overflows (a panic in dev profiles) and never produces a frame. Found by the v2.7.0 save_state fuzz target in 76,381 runs (ppu.rs:6078, dot += 1).

Fields

§dot: u16

The restored dot.

§scanline: i16

The restored scanline.

Trait Implementations§

Source§

impl Debug for PpuSnapshotError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PpuSnapshotError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for PpuSnapshotError

1.30.0 · Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.