Skip to main content

Limits

Struct Limits 

Source
pub struct Limits {
Show 20 fields pub max_text_bytes: usize, pub max_definitions: usize, pub max_palette_colors: usize, pub max_sprite_side: u32, pub max_layers: usize, pub max_frames: usize, pub max_tiles: usize, pub max_map_side: u32, pub max_glyphs: usize, pub max_kerning_pairs: usize, pub max_export_files: usize, pub max_screen_items: usize, pub max_scene_commands: usize, pub max_scene_pixels: u64, pub max_scene_work: u64, pub max_scatter_attempts: u64, pub max_nesting: usize, pub max_image_side: u32, pub max_image_pixels: u64, pub max_warnings: usize,
}
Expand description

Bounds on input and output, checked while text is parsed, before images are allocated and while PNG files are decoded.

The defaults suit hand-written files and untrusted input. Raise them for trusted input that needs more:

use spritebox::{Document, Limits};

let limits = Limits { max_sprite_side: 4096, ..Limits::default() };
let document = Document::parse_with("palette p\n  x #ff0000\n", &limits)?;

Fields§

§max_text_bytes: usize

Length of the text in bytes. Default 4 MiB.

§max_definitions: usize

Number of top-level definitions: palettes, sprites and so on. Default 4096.

§max_palette_colors: usize

Keys in one palette, inherited keys included. Default 256.

§max_sprite_side: u32

Width or height of one sprite in pixels. Default 1024.

§max_layers: usize

Layers in one sprite, layers of sprites used as layers included. Default 16.

§max_frames: usize

Frames in one animation. Default 1024.

§max_tiles: usize

Tiles in one tileset, terrain variants included. Default 4096.

§max_map_side: u32

Width or height of one tilemap in tiles. Default 1024.

§max_glyphs: usize

Glyphs in one font. Default 4096.

§max_kerning_pairs: usize

Kerning pairs in one font. Default 4096.

§max_export_files: usize

Files in an export, including theme variants. Default 8192.

§max_screen_items: usize

Placements in one screen. Default 1024.

§max_scene_commands: usize

Authored scene operations and list records. Default 4096.

§max_scene_pixels: u64

Retained scene cells, profile entries, placements and operation images. Default 16 Mi.

§max_scene_work: u64

Raster samples, edge tests, noise octaves and scatter work per operation. Default 64 Mi.

§max_scatter_attempts: u64

Candidate attempts across all scatter groups in a document. Default 1,000,000.

§max_nesting: usize

Depth of definitions built on other definitions: palettes copied from= another, and sprites derived from sprites. Default 32.

§max_image_side: u32

Width or height of any image the crate creates or decodes, previews and atlases included. Default 8192.

§max_image_pixels: u64

Pixels of any image the crate creates or decodes, and of all the sprites of a document together. Default 16 Mi (64 MiB of RGBA8).

§max_warnings: usize

Warnings that Document::lint keeps; its counts include those left out. Default 1000.

Implementations§

Source§

impl Limits

Source

pub fn check_image(&self, width: u32, height: u32) -> Result<()>

Checks that an image of width × height pixels is within the image limits.

Trait Implementations§

Source§

impl Clone for Limits

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Limits

Source§

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

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

impl Default for Limits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Limits

Source§

impl PartialEq for Limits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Limits

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.