Skip to main content

parse_bytes_with_limits

Function parse_bytes_with_limits 

Source
pub fn parse_bytes_with_limits(
    bytes: Vec<u8>,
    limits: &ParseLimits,
) -> Result<ParsedModel>
Expand description

Parses owned .safetensors bytes under a caller-supplied ParseLimits budget — the bounded, mmap-free path for untrusted input.

Rejects an input larger than ParseLimits::max_single_alloc_bytes before parsing, then enforces every applicable ParseLimits ceiling on the header exactly as parse_with_limits does.

§Errors

Returns AnamnesisError::LimitExceeded if bytes exceeds limits. Returns AnamnesisError::Parse if the safetensors header is malformed.

§Memory

Takes ownership of bytes (no copy); peak heap is the input size.