#[non_exhaustive]pub struct DecodeLimits {
pub max_points: u64,
pub max_faces: u64,
pub max_decoded_bytes: u64,
}Expand description
Ceilings on one decode, applied to what the stream reconstructs.
Every field is a hard ceiling: exceeding one fails the decode with
ErrorKind::LimitExceeded, which a caller can tell apart from
ErrorKind::AllocationExceedsInput – its own policy refusing a large
file, rather than the decoder refusing a malformed one.
The counts are the decoded ones, not the ones a source file was authored with. Draco splits a point wherever an attribute seam runs through it, and the growth is real: measured across ten assets it runs from zero to 7.7%, and one exporter’s 65,532-point primitive decodes to 76,742. A ceiling derived from what an exporter writes would refuse files that follow its own convention.
Install with DecoderBuffer::with_limits.
use draco_core::{DecodeLimits, DecoderBuffer};
let stream = [0u8; 0];
let buffer = DecoderBuffer::new(&stream)
.with_limits(DecodeLimits::default().with_max_points(1_000_000));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_points: u64Largest accepted decoded point count.
max_faces: u64Largest accepted decoded face count.
max_decoded_bytes: u64Largest accepted total size of decoded attribute values, in bytes.
This is the one that bounds memory. The other two are proxies whose relationship to bytes the attribute set moves around: of two measured assets, the one with a third fewer points held twice the bytes per primitive, because it carried tangents and five texture-coordinate sets against a position and a normal.
Implementations§
Source§impl DecodeLimits
impl DecodeLimits
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
No ceiling at all, which is what this crate did before the type existed.
For a caller that decodes trusted local input and would rather have a scan loaded whole than a refusal.
Source§impl DecodeLimits
impl DecodeLimits
Sourcepub fn with_max_points(self, value: u64) -> Self
pub fn with_max_points(self, value: u64) -> Self
Sets Self::max_points.
Sourcepub fn with_max_faces(self, value: u64) -> Self
pub fn with_max_faces(self, value: u64) -> Self
Sets Self::max_faces.
Sourcepub fn with_max_decoded_bytes(self, value: u64) -> Self
pub fn with_max_decoded_bytes(self, value: u64) -> Self
Sets Self::max_decoded_bytes.