pub struct DecodeContext<'a> { /* private fields */ }Expand description
Shared monotonic decode state.
Implementations§
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn reserve_capacity_limit<T>(
&self,
values: &mut Vec<T>,
count: usize,
operation: &'static str,
) -> Result<(), ResourceLimit>
pub fn reserve_capacity_limit<T>( &self, values: &mut Vec<T>, count: usize, operation: &'static str, ) -> Result<(), ResourceLimit>
Reserve backing storage without admitting values not yet inserted.
Sourcepub fn reserve_capacity<T>(
&self,
values: &mut Vec<T>,
count: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_capacity<T>( &self, values: &mut Vec<T>, count: usize, operation: &'static str, ) -> Result<(), CodecError>
Retains vector storage whose slots were admitted in aggregate.
Sourcepub fn vector_storage<T>(
&self,
count: usize,
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn vector_storage<T>( &self, count: usize, operation: &'static str, ) -> Result<Vec<T>, CodecError>
Creates retained storage whose collection slots are admitted separately.
Sourcepub fn reserve_scoped_collection<T>(
&self,
count: usize,
operation: &'static str,
) -> Result<ScopedReservation<'_>, CodecError>
pub fn reserve_scoped_collection<T>( &self, count: usize, operation: &'static str, ) -> Result<ScopedReservation<'_>, CodecError>
Admits scoped collection slots whose storage is allocated by a later operation.
Sourcepub fn scoped_vector_storage<T>(
&self,
count: usize,
operation: &'static str,
) -> Result<(Vec<T>, ScopedReservation<'_>), CodecError>
pub fn scoped_vector_storage<T>( &self, count: usize, operation: &'static str, ) -> Result<(Vec<T>, ScopedReservation<'_>), CodecError>
Creates scoped storage whose collection slots are admitted separately.
Sourcepub fn reserve_scoped_vec<T>(
&self,
reservation: &mut ScopedReservation<'_>,
values: &mut Vec<T>,
count: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_scoped_vec<T>( &self, reservation: &mut ScopedReservation<'_>, values: &mut Vec<T>, count: usize, operation: &'static str, ) -> Result<(), CodecError>
Grows scoped storage and admits additional vector slots.
Sourcepub fn reserve_scoped_vec_limit<T>(
&self,
reservation: &mut ScopedReservation<'_>,
values: &mut Vec<T>,
count: usize,
operation: &'static str,
) -> Result<(), ResourceLimit>
pub fn reserve_scoped_vec_limit<T>( &self, reservation: &mut ScopedReservation<'_>, values: &mut Vec<T>, count: usize, operation: &'static str, ) -> Result<(), ResourceLimit>
Reserves storage with a resource-only refusal channel.
Sourcepub fn push_scoped_vec<T>(
&self,
reservation: &mut ScopedReservation<'_>,
values: &mut Vec<T>,
value: T,
operation: &'static str,
) -> Result<(), CodecError>
pub fn push_scoped_vec<T>( &self, reservation: &mut ScopedReservation<'_>, values: &mut Vec<T>, value: T, operation: &'static str, ) -> Result<(), CodecError>
Appends one item with scoped storage and a charged collection slot.
Sourcepub fn reserve_temporary_vec<T>(
&self,
values: &mut Vec<T>,
count: usize,
operation: &'static str,
) -> Result<ScopedReservation<'_>, ResourceLimit>
pub fn reserve_temporary_vec<T>( &self, values: &mut Vec<T>, count: usize, operation: &'static str, ) -> Result<ScopedReservation<'_>, ResourceLimit>
Reserves temporary vector storage and returns its live byte reservation.
Sourcepub fn copy_temporary_slice<T: Copy>(
&self,
values: &[T],
operation: &'static str,
) -> Result<(Vec<T>, ScopedReservation<'_>), ResourceLimit>
pub fn copy_temporary_slice<T: Copy>( &self, values: &[T], operation: &'static str, ) -> Result<(Vec<T>, ScopedReservation<'_>), ResourceLimit>
Copies a slice into scoped storage and returns its live byte reservation.
Sourcepub fn collect_retained_texts<'text>(
&self,
values: impl IntoIterator<Item = &'text str>,
operation: &'static str,
) -> Result<Vec<String>, CodecError>
pub fn collect_retained_texts<'text>( &self, values: impl IntoIterator<Item = &'text str>, operation: &'static str, ) -> Result<Vec<String>, CodecError>
Collects retained text and charges both vector storage and text bytes.
Sourcepub fn collect_scoped_texts<'text>(
&self,
values: impl IntoIterator<Item = &'text str>,
operation: &'static str,
) -> Result<(Vec<String>, ScopedReservation<'_>), CodecError>
pub fn collect_scoped_texts<'text>( &self, values: impl IntoIterator<Item = &'text str>, operation: &'static str, ) -> Result<(Vec<String>, ScopedReservation<'_>), CodecError>
Copies scoped text values and returns the reservation for their storage.
Sourcepub fn format_scoped_text(
&self,
reservation: &mut ScopedReservation<'_>,
args: Arguments<'_>,
operation: &'static str,
) -> Result<String, CodecError>
pub fn format_scoped_text( &self, reservation: &mut ScopedReservation<'_>, args: Arguments<'_>, operation: &'static str, ) -> Result<String, CodecError>
Formats text in an existing scope after charging its byte count as work.
Sourcepub fn reserve_record_vec<T>(
&self,
records: &mut Vec<T>,
count: usize,
text_bytes: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_record_vec<T>( &self, records: &mut Vec<T>, count: usize, text_bytes: u64, operation: &'static str, ) -> Result<(), CodecError>
Admits records, retains their storage and additional text, and reserves slots.
Sourcepub fn collect_retained_vec<T>(
&self,
values: impl IntoIterator<Item = T>,
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn collect_retained_vec<T>( &self, values: impl IntoIterator<Item = T>, operation: &'static str, ) -> Result<Vec<T>, CodecError>
Collects retained slots before adding each value.
Sourcepub fn charge_btree_lookup(
&self,
len: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_btree_lookup( &self, len: usize, operation: &'static str, ) -> Result<(), CodecError>
Admits the comparison bound for one standard-library B-tree lookup.
Sourcepub fn insert_scoped_btree_set<T: Ord>(
&self,
reservation: &mut ScopedReservation<'_>,
values: &mut BTreeSet<T>,
value: T,
work_operation: &'static str,
operation: &'static str,
) -> Result<bool, CodecError>
pub fn insert_scoped_btree_set<T: Ord>( &self, reservation: &mut ScopedReservation<'_>, values: &mut BTreeSet<T>, value: T, work_operation: &'static str, operation: &'static str, ) -> Result<bool, CodecError>
Inserts a new scoped tree key after charging lookup work and node storage.
Sourcepub fn insert_scoped_btree_map_if_vacant<K: Ord, V>(
&self,
reservation: &mut ScopedReservation<'_>,
values: &mut BTreeMap<K, V>,
key: K,
value: V,
work_operation: &'static str,
operation: &'static str,
) -> Result<bool, CodecError>
pub fn insert_scoped_btree_map_if_vacant<K: Ord, V>( &self, reservation: &mut ScopedReservation<'_>, values: &mut BTreeMap<K, V>, key: K, value: V, work_operation: &'static str, operation: &'static str, ) -> Result<bool, CodecError>
Inserts a vacant scoped tree entry after charging lookup work and node storage.
Sourcepub fn push_scoped_btree_group<K: Ord, V>(
&self,
reservation: &mut ScopedReservation<'_>,
groups: &mut BTreeMap<K, Vec<V>>,
key: K,
value: impl FnOnce() -> V,
owned_bytes: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn push_scoped_btree_group<K: Ord, V>( &self, reservation: &mut ScopedReservation<'_>, groups: &mut BTreeMap<K, Vec<V>>, key: K, value: impl FnOnce() -> V, owned_bytes: usize, operation: &'static str, ) -> Result<(), CodecError>
Appends a lazily built value to a scoped group after aggregate admission.
Sourcepub fn admit_retained_btree_record<K, V>(
&self,
owned_bytes: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn admit_retained_btree_record<K, V>( &self, owned_bytes: usize, operation: &'static str, ) -> Result<(), CodecError>
Admits tree-record storage, owned bytes, one slot and one work unit.
Without the current tree length, each record admits one backing node.
Sourcepub fn collect_scoped_btree_groups<'ctx, K: Ord, V>(
&'ctx self,
values: impl IntoIterator<Item = (K, V)>,
operation: &'static str,
) -> Result<(BTreeMap<K, Vec<V>>, ScopedReservation<'ctx>), CodecError>
pub fn collect_scoped_btree_groups<'ctx, K: Ord, V>( &'ctx self, values: impl IntoIterator<Item = (K, V)>, operation: &'static str, ) -> Result<(BTreeMap<K, Vec<V>>, ScopedReservation<'ctx>), CodecError>
Collects scoped groups in input order within each key.
Sourcepub fn collect_scoped_btree_map<'ctx, K: Ord, V>(
&'ctx self,
values: impl IntoIterator<Item = (K, V)>,
operation: &'static str,
) -> Result<(BTreeMap<K, V>, ScopedReservation<'ctx>), CodecError>
pub fn collect_scoped_btree_map<'ctx, K: Ord, V>( &'ctx self, values: impl IntoIterator<Item = (K, V)>, operation: &'static str, ) -> Result<(BTreeMap<K, V>, ScopedReservation<'ctx>), CodecError>
Collects scoped entries, keeping the last value for each key.
Sourcepub fn reserve_scoped_string(
&self,
reservation: &mut ScopedReservation<'_>,
text: &mut String,
additional: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_scoped_string( &self, reservation: &mut ScopedReservation<'_>, text: &mut String, additional: usize, operation: &'static str, ) -> Result<(), CodecError>
Grows a scoped string after admitting its additional byte storage.
Sourcepub fn scoped_string(
&self,
length: usize,
operation: &'static str,
) -> Result<(String, ScopedReservation<'_>), CodecError>
pub fn scoped_string( &self, length: usize, operation: &'static str, ) -> Result<(String, ScopedReservation<'_>), CodecError>
Creates empty scoped text with fallible storage admission.
Sourcepub fn collection_vec<T>(
&self,
count: usize,
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn collection_vec<T>( &self, count: usize, operation: &'static str, ) -> Result<Vec<T>, CodecError>
Allocates a vector for count admitted items.
Sourcepub fn reserve_vec<T>(
&self,
values: &mut Vec<T>,
additional: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_vec<T>( &self, values: &mut Vec<T>, additional: usize, operation: &'static str, ) -> Result<(), CodecError>
Reserves additional vector items and charges their admission.
Sourcepub fn reserve_vec_limit<T>(
&self,
values: &mut Vec<T>,
additional: usize,
operation: &'static str,
) -> Result<(), ResourceLimit>
pub fn reserve_vec_limit<T>( &self, values: &mut Vec<T>, additional: usize, operation: &'static str, ) -> Result<(), ResourceLimit>
Reserves storage with a resource-only refusal channel.
Sourcepub fn collect_indexed_vec<T>(
&self,
count: usize,
operation: &'static str,
value_at: impl FnMut(usize) -> Result<T, CodecError>,
) -> Result<Vec<T>, CodecError>
pub fn collect_indexed_vec<T>( &self, count: usize, operation: &'static str, value_at: impl FnMut(usize) -> Result<T, CodecError>, ) -> Result<Vec<T>, CodecError>
Builds a vector of indexed values after charging all slots.
Sourcepub fn push_vec<T>(
&self,
values: &mut Vec<T>,
value: T,
operation: &'static str,
) -> Result<(), CodecError>
pub fn push_vec<T>( &self, values: &mut Vec<T>, value: T, operation: &'static str, ) -> Result<(), CodecError>
Adds one vector item after charging its slot.
Sourcepub fn push_formatted_retained(
&self,
values: &mut Vec<String>,
args: Arguments<'_>,
slots_operation: &'static str,
text_operation: &'static str,
) -> Result<(), CodecError>
pub fn push_formatted_retained( &self, values: &mut Vec<String>, args: Arguments<'_>, slots_operation: &'static str, text_operation: &'static str, ) -> Result<(), CodecError>
Adds a formatted retained note after charging its collection slot.
Sourcepub fn append_vec<T>(
&self,
target: &mut Vec<T>,
source: &mut Vec<T>,
operation: &'static str,
) -> Result<(), CodecError>
pub fn append_vec<T>( &self, target: &mut Vec<T>, source: &mut Vec<T>, operation: &'static str, ) -> Result<(), CodecError>
Moves all source items into a vector after charging their slots.
Sourcepub fn extend_vec<T>(
&self,
target: &mut Vec<T>,
source: Vec<T>,
operation: &'static str,
) -> Result<(), CodecError>
pub fn extend_vec<T>( &self, target: &mut Vec<T>, source: Vec<T>, operation: &'static str, ) -> Result<(), CodecError>
Moves owned items into a vector after charging their slots.
Sourcepub fn collect_vec<T>(
&self,
values: impl IntoIterator<Item = T>,
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn collect_vec<T>( &self, values: impl IntoIterator<Item = T>, operation: &'static str, ) -> Result<Vec<T>, CodecError>
Collects iterator values with a charged slot for each value.
Sourcepub fn try_collect_vec<T, E: From<CodecError>>(
&self,
values: impl IntoIterator<Item = Result<T, E>>,
operation: &'static str,
) -> Result<Vec<T>, E>
pub fn try_collect_vec<T, E: From<CodecError>>( &self, values: impl IntoIterator<Item = Result<T, E>>, operation: &'static str, ) -> Result<Vec<T>, E>
Collects fallible iterator values with a charged slot for each success.
Sourcepub fn insert_scoped_btree_value<T: Ord>(
&self,
reservation: &mut ScopedReservation<'_>,
values: &mut BTreeSet<T>,
value: T,
operation: &'static str,
) -> Result<bool, CodecError>
pub fn insert_scoped_btree_value<T: Ord>( &self, reservation: &mut ScopedReservation<'_>, values: &mut BTreeSet<T>, value: T, operation: &'static str, ) -> Result<bool, CodecError>
Inserts a unique tree value after admitting its scoped value storage.
Sourcepub fn insert_hash_set<T: Eq + Hash>(
&self,
values: &mut HashSet<T>,
value: T,
operation: &'static str,
) -> Result<bool, CodecError>
pub fn insert_hash_set<T: Eq + Hash>( &self, values: &mut HashSet<T>, value: T, operation: &'static str, ) -> Result<bool, CodecError>
Inserts a new set item after charging its slot.
Sourcepub fn insert_string_set(
&self,
values: &mut HashSet<String>,
value: &str,
operation: &'static str,
) -> Result<bool, CodecError>
pub fn insert_string_set( &self, values: &mut HashSet<String>, value: &str, operation: &'static str, ) -> Result<bool, CodecError>
Inserts a copied string into a set if the value is new.
Sourcepub fn extend_hash_set<T: Eq + Hash>(
&self,
values: &mut HashSet<T>,
additions: impl IntoIterator<Item = T>,
operation: &'static str,
) -> Result<(), CodecError>
pub fn extend_hash_set<T: Eq + Hash>( &self, values: &mut HashSet<T>, additions: impl IntoIterator<Item = T>, operation: &'static str, ) -> Result<(), CodecError>
Extends a set with one charged slot for each distinct new value.
Sourcepub fn collect_hash_set<T: Eq + Hash>(
&self,
values: impl IntoIterator<Item = T>,
operation: &'static str,
) -> Result<HashSet<T>, CodecError>
pub fn collect_hash_set<T: Eq + Hash>( &self, values: impl IntoIterator<Item = T>, operation: &'static str, ) -> Result<HashSet<T>, CodecError>
Collects distinct values into a charged hash set.
Sourcepub fn admit_hash_map_entry<K: Eq + Hash, V>(
&self,
values: &mut HashMap<K, V>,
key: &K,
operation: &'static str,
) -> Result<(), CodecError>
pub fn admit_hash_map_entry<K: Eq + Hash, V>( &self, values: &mut HashMap<K, V>, key: &K, operation: &'static str, ) -> Result<(), CodecError>
Reserves a map slot only when the key is new.
Sourcepub fn push_hash_group<K: Eq + Hash, V>(
&self,
values: &mut HashMap<K, Vec<V>>,
key: K,
value: V,
index_operation: &'static str,
value_operation: &'static str,
) -> Result<(), CodecError>
pub fn push_hash_group<K: Eq + Hash, V>( &self, values: &mut HashMap<K, Vec<V>>, key: K, value: V, index_operation: &'static str, value_operation: &'static str, ) -> Result<(), CodecError>
Appends a grouped value after admitting both new index and value slots.
Sourcepub fn insert_hash_map<K: Eq + Hash, V>(
&self,
values: &mut HashMap<K, V>,
key: K,
value: V,
operation: &'static str,
) -> Result<Option<V>, CodecError>
pub fn insert_hash_map<K: Eq + Hash, V>( &self, values: &mut HashMap<K, V>, key: K, value: V, operation: &'static str, ) -> Result<Option<V>, CodecError>
Inserts a map entry after admitting a new key, if needed.
Sourcepub fn collect_hash_map<K: Eq + Hash, V>(
&self,
values: impl IntoIterator<Item = (K, V)>,
operation: &'static str,
) -> Result<HashMap<K, V>, CodecError>
pub fn collect_hash_map<K: Eq + Hash, V>( &self, values: impl IntoIterator<Item = (K, V)>, operation: &'static str, ) -> Result<HashMap<K, V>, CodecError>
Collects entries into a charged hash map.
Sourcepub fn copy_scoped_text(
&self,
text: &str,
reservation: &mut ScopedReservation<'_>,
operation: &'static str,
) -> Result<String, CodecError>
pub fn copy_scoped_text( &self, text: &str, reservation: &mut ScopedReservation<'_>, operation: &'static str, ) -> Result<String, CodecError>
Copies temporary text while its scoped reservation remains live.
Sourcepub fn push_back<T>(
&self,
values: &mut VecDeque<T>,
value: T,
operation: &'static str,
) -> Result<(), CodecError>
pub fn push_back<T>( &self, values: &mut VecDeque<T>, value: T, operation: &'static str, ) -> Result<(), CodecError>
Appends a deque item after charging its slot.
Sourcepub fn push_front<T>(
&self,
values: &mut VecDeque<T>,
value: T,
operation: &'static str,
) -> Result<(), CodecError>
pub fn push_front<T>( &self, values: &mut VecDeque<T>, value: T, operation: &'static str, ) -> Result<(), CodecError>
Prepends a deque item after charging its slot.
Sourcepub fn reserve_heap<T: Ord>(
&self,
values: &mut BinaryHeap<T>,
count: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_heap<T: Ord>( &self, values: &mut BinaryHeap<T>, count: usize, operation: &'static str, ) -> Result<(), CodecError>
Reserves slots in a binary heap after charging them.
Sourcepub fn optional_collection_vec<T>(
&self,
present: bool,
count: usize,
operation: &'static str,
) -> Result<Option<Vec<T>>, CodecError>
pub fn optional_collection_vec<T>( &self, present: bool, count: usize, operation: &'static str, ) -> Result<Option<Vec<T>>, CodecError>
Creates a charged vector only when the source is present.
Sourcepub fn copy_rows<T: Copy>(
&self,
values: &[T],
row_len: usize,
row_operation: &'static str,
item_operation: &'static str,
) -> Result<Vec<Vec<T>>, CodecError>
pub fn copy_rows<T: Copy>( &self, values: &[T], row_len: usize, row_operation: &'static str, item_operation: &'static str, ) -> Result<Vec<Vec<T>>, CodecError>
Copies a flat lane into rows after admitting every row and element slot.
Sourcepub fn try_collect_retained_with<I, T, E: From<CodecError>>(
&self,
values: impl IntoIterator<Item = I>,
operation: &'static str,
map: impl FnMut(I) -> Result<T, E>,
) -> Result<Vec<T>, E>
pub fn try_collect_retained_with<I, T, E: From<CodecError>>( &self, values: impl IntoIterator<Item = I>, operation: &'static str, map: impl FnMut(I) -> Result<T, E>, ) -> Result<Vec<T>, E>
Collects fallible values and admits the storage of each output slot.
Sourcepub fn copy_slice<T: Copy>(
&self,
values: &[T],
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn copy_slice<T: Copy>( &self, values: &[T], operation: &'static str, ) -> Result<Vec<T>, CodecError>
Copies a slice after charging its collection slots.
Sourcepub fn collect_options<T>(
&self,
values: impl IntoIterator<Item = Option<T>>,
operation: &'static str,
) -> Result<Option<Vec<T>>, CodecError>
pub fn collect_options<T>( &self, values: impl IntoIterator<Item = Option<T>>, operation: &'static str, ) -> Result<Option<Vec<T>>, CodecError>
Collects optional values, stopping at the first absent value.
Sourcepub fn collect_fallible_options<T, E: Into<CodecError>>(
&self,
values: impl IntoIterator<Item = Result<Option<T>, E>>,
operation: &'static str,
) -> Result<Option<Vec<T>>, CodecError>
pub fn collect_fallible_options<T, E: Into<CodecError>>( &self, values: impl IntoIterator<Item = Result<Option<T>, E>>, operation: &'static str, ) -> Result<Option<Vec<T>>, CodecError>
Collects fallible optional values, stopping at the first absent value.
Sourcepub fn collect_string_set<'a>(
&self,
values: impl IntoIterator<Item = &'a str>,
operation: &'static str,
) -> Result<HashSet<String>, CodecError>
pub fn collect_string_set<'a>( &self, values: impl IntoIterator<Item = &'a str>, operation: &'static str, ) -> Result<HashSet<String>, CodecError>
Collects retained strings into a charged hash set.
Sourcepub fn copy_retained_rows<T: Copy>(
&self,
rows: &[Vec<T>],
row_operation: &'static str,
item_operation: &'static str,
) -> Result<Vec<Vec<T>>, CodecError>
pub fn copy_retained_rows<T: Copy>( &self, rows: &[Vec<T>], row_operation: &'static str, item_operation: &'static str, ) -> Result<Vec<Vec<T>>, CodecError>
Copies retained rows and charges row and item slots.
Sourcepub fn copy_retained_set<T: Copy + Eq + Hash>(
&self,
values: &HashSet<T>,
operation: &'static str,
) -> Result<HashSet<T>, CodecError>
pub fn copy_retained_set<T: Copy + Eq + Hash>( &self, values: &HashSet<T>, operation: &'static str, ) -> Result<HashSet<T>, CodecError>
Copies a retained set after charging storage and entries.
Sourcepub fn reserve_set<T: Eq + Hash>(
&self,
values: &mut HashSet<T>,
count: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_set<T: Eq + Hash>( &self, values: &mut HashSet<T>, count: usize, operation: &'static str, ) -> Result<(), CodecError>
Reserves hash set entries after charging their slots.
Sourcepub fn reserve_map<K: Eq + Hash, V>(
&self,
values: &mut HashMap<K, V>,
count: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn reserve_map<K: Eq + Hash, V>( &self, values: &mut HashMap<K, V>, count: usize, operation: &'static str, ) -> Result<(), CodecError>
Reserves hash map entries after charging their slots.
Sourcepub fn admit_btree_node_storage<K, V>(
&self,
len: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn admit_btree_node_storage<K, V>( &self, len: usize, operation: &'static str, ) -> Result<(), CodecError>
Admits the backing nodes for one ordered entry whose slot is already charged.
Sourcepub fn admit_btree_entry<K: Ord, V>(
&self,
values: &BTreeMap<K, V>,
key: &K,
operation: &'static str,
) -> Result<(), CodecError>
pub fn admit_btree_entry<K: Ord, V>( &self, values: &BTreeMap<K, V>, key: &K, operation: &'static str, ) -> Result<(), CodecError>
Charges a new B-tree map key before insertion.
Sourcepub fn insert_btree_map<K: Ord, V>(
&self,
values: &mut BTreeMap<K, V>,
key: K,
value: V,
operation: &'static str,
) -> Result<Option<V>, CodecError>
pub fn insert_btree_map<K: Ord, V>( &self, values: &mut BTreeMap<K, V>, key: K, value: V, operation: &'static str, ) -> Result<Option<V>, CodecError>
Inserts a B-tree map entry after charging a new key.
Sourcepub fn insert_btree_set<T: Ord>(
&self,
values: &mut BTreeSet<T>,
value: T,
operation: &'static str,
) -> Result<bool, CodecError>
pub fn insert_btree_set<T: Ord>( &self, values: &mut BTreeSet<T>, value: T, operation: &'static str, ) -> Result<bool, CodecError>
Inserts a B-tree set item after charging a new value.
Sourcepub fn collect_btree_set<T: Ord>(
&self,
values: impl IntoIterator<Item = T>,
operation: &'static str,
) -> Result<BTreeSet<T>, CodecError>
pub fn collect_btree_set<T: Ord>( &self, values: impl IntoIterator<Item = T>, operation: &'static str, ) -> Result<BTreeSet<T>, CodecError>
Collects distinct ordered values after admitting each new entry.
Sourcepub fn push_btree_group<K: Ord, V>(
&self,
groups: &mut BTreeMap<K, Vec<V>>,
key: K,
value: V,
group_operation: &'static str,
item_operation: &'static str,
) -> Result<(), CodecError>
pub fn push_btree_group<K: Ord, V>( &self, groups: &mut BTreeMap<K, Vec<V>>, key: K, value: V, group_operation: &'static str, item_operation: &'static str, ) -> Result<(), CodecError>
Appends an ordered group member after admitting its group and slot.
Sourcepub fn insert_btree_group_set<K: Ord, V: Ord>(
&self,
groups: &mut BTreeMap<K, BTreeSet<V>>,
key: K,
value: V,
group_operation: &'static str,
item_operation: &'static str,
) -> Result<(), CodecError>
pub fn insert_btree_group_set<K: Ord, V: Ord>( &self, groups: &mut BTreeMap<K, BTreeSet<V>>, key: K, value: V, group_operation: &'static str, item_operation: &'static str, ) -> Result<(), CodecError>
Inserts an ordered group member after admitting its group and value.
Sourcepub fn resize_retained_bytes(
&self,
values: &mut Vec<u8>,
length: usize,
fill: u8,
operation: &'static str,
) -> Result<(), CodecError>
pub fn resize_retained_bytes( &self, values: &mut Vec<u8>, length: usize, fill: u8, operation: &'static str, ) -> Result<(), CodecError>
Resizes a byte buffer after admitting additional retained storage.
Sourcepub fn extend_retained_bytes(
&self,
target: &mut Vec<u8>,
source: &[u8],
operation: &'static str,
) -> Result<(), CodecError>
pub fn extend_retained_bytes( &self, target: &mut Vec<u8>, source: &[u8], operation: &'static str, ) -> Result<(), CodecError>
Extends retained bytes after charging both their slots and storage.
Sourcepub fn temporary_vec<T>(
&self,
count: usize,
operation: &'static str,
) -> Result<(Vec<T>, ScopedReservation<'_>), CodecError>
pub fn temporary_vec<T>( &self, count: usize, operation: &'static str, ) -> Result<(Vec<T>, ScopedReservation<'_>), CodecError>
Reserves a scoped vector and returns its live reservation.
Sourcepub fn temporary_set<T: Eq + Hash>(
&self,
count: usize,
operation: &'static str,
) -> Result<(HashSet<T>, ScopedReservation<'_>), CodecError>
pub fn temporary_set<T: Eq + Hash>( &self, count: usize, operation: &'static str, ) -> Result<(HashSet<T>, ScopedReservation<'_>), CodecError>
Reserves a scoped hash set and returns its live reservation.
Sourcepub fn temporary_set_limit<T: Eq + Hash>(
&self,
count: usize,
operation: &'static str,
) -> Result<(HashSet<T>, ScopedReservation<'_>), ResourceLimit>
pub fn temporary_set_limit<T: Eq + Hash>( &self, count: usize, operation: &'static str, ) -> Result<(HashSet<T>, ScopedReservation<'_>), ResourceLimit>
Reserves a scoped hash set with a typed resource error.
Sourcepub fn collect_scoped_string_set<'text>(
&self,
count: usize,
values: impl IntoIterator<Item = &'text str>,
operation: &'static str,
) -> Result<(HashSet<&'text str>, ScopedReservation<'_>), CodecError>
pub fn collect_scoped_string_set<'text>( &self, count: usize, values: impl IntoIterator<Item = &'text str>, operation: &'static str, ) -> Result<(HashSet<&'text str>, ScopedReservation<'_>), CodecError>
Collects a borrowed string index with scoped hash storage.
Sourcepub fn collect_scoped_string_map<'text, V>(
&self,
count: usize,
values: impl IntoIterator<Item = (&'text str, V)>,
operation: &'static str,
) -> Result<(HashMap<&'text str, V>, ScopedReservation<'_>), CodecError>
pub fn collect_scoped_string_map<'text, V>( &self, count: usize, values: impl IntoIterator<Item = (&'text str, V)>, operation: &'static str, ) -> Result<(HashMap<&'text str, V>, ScopedReservation<'_>), CodecError>
Collects a borrowed string-keyed index with scoped hash storage.
Sourcepub fn temporary_queue<T>(
&self,
count: usize,
operation: &'static str,
) -> Result<(VecDeque<T>, ScopedReservation<'_>), CodecError>
pub fn temporary_queue<T>( &self, count: usize, operation: &'static str, ) -> Result<(VecDeque<T>, ScopedReservation<'_>), CodecError>
Reserves a scoped deque and returns its live reservation.
Sourcepub fn charge_formatted_retained(
&self,
args: Arguments<'_>,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_formatted_retained( &self, args: Arguments<'_>, operation: &'static str, ) -> Result<(), CodecError>
Charges retained text produced by a later aggregate materialization.
Sourcepub fn format_retained(
&self,
args: Arguments<'_>,
operation: &'static str,
) -> Result<String, CodecError>
pub fn format_retained( &self, args: Arguments<'_>, operation: &'static str, ) -> Result<String, CodecError>
Formats a retained string after charging its exact byte count.
Sourcepub fn format_scoped(
&self,
args: Arguments<'_>,
operation: &'static str,
) -> Result<(String, ScopedReservation<'_>), CodecError>
pub fn format_scoped( &self, args: Arguments<'_>, operation: &'static str, ) -> Result<(String, ScopedReservation<'_>), CodecError>
Formats a temporary string and returns its live reservation.
Sourcepub fn append_retained(
&self,
output: &mut String,
suffix: &str,
operation: &'static str,
) -> Result<(), CodecError>
pub fn append_retained( &self, output: &mut String, suffix: &str, operation: &'static str, ) -> Result<(), CodecError>
Appends retained text after charging its bytes.
Sourcepub fn append_formatted_retained(
&self,
output: &mut String,
args: Arguments<'_>,
operation: &'static str,
) -> Result<(), CodecError>
pub fn append_formatted_retained( &self, output: &mut String, args: Arguments<'_>, operation: &'static str, ) -> Result<(), CodecError>
Appends formatted text after admitting its exact retained byte count.
Sourcepub fn retained_string(
&self,
length: usize,
operation: &'static str,
) -> Result<String, CodecError>
pub fn retained_string( &self, length: usize, operation: &'static str, ) -> Result<String, CodecError>
Reserves an empty retained string after charging its declared length.
Sourcepub fn retained_suffix(
&self,
value: &str,
suffix: &str,
operation: &'static str,
) -> Result<String, CodecError>
pub fn retained_suffix( &self, value: &str, suffix: &str, operation: &'static str, ) -> Result<String, CodecError>
Copies retained text and appends a retained suffix.
Sourcepub fn copy_retained_strings(
&self,
values: &[String],
operation: &'static str,
) -> Result<Vec<String>, CodecError>
pub fn copy_retained_strings( &self, values: &[String], operation: &'static str, ) -> Result<Vec<String>, CodecError>
Copies a slice of retained strings after charging collection slots.
Sourcepub fn join_retained<S: AsRef<str>>(
&self,
parts: &[S],
separator: &str,
operation: &'static str,
) -> Result<String, CodecError>
pub fn join_retained<S: AsRef<str>>( &self, parts: &[S], separator: &str, operation: &'static str, ) -> Result<String, CodecError>
Joins retained text after measuring and charging the exact byte count.
Sourcepub fn join_display_retained<T: Display>(
&self,
values: impl IntoIterator<Item = T>,
separator: &str,
operation: &'static str,
) -> Result<String, CodecError>
pub fn join_display_retained<T: Display>( &self, values: impl IntoIterator<Item = T>, separator: &str, operation: &'static str, ) -> Result<String, CodecError>
Joins displayed values while charging each retained text fragment.
Source§impl<'a> DecodeContext<'a>
impl<'a> DecodeContext<'a>
Sourcepub fn new(
arena: &'a DecodeArena,
policy: &DecodePolicy,
container_only: bool,
) -> Self
pub fn new( arena: &'a DecodeArena, policy: &DecodePolicy, container_only: bool, ) -> Self
Creates one session before input acquisition and detection.
Sourcepub fn for_loaded_input(
arena: &'a DecodeArena,
policy: &DecodePolicy,
input_bytes: u64,
) -> Result<Self, CodecError>
pub fn for_loaded_input( arena: &'a DecodeArena, policy: &DecodePolicy, input_bytes: u64, ) -> Result<Self, CodecError>
Starts post-decode processing with the measured byte length of an already loaded input. This admits the input-proportional allowances without keeping another copy of the source bytes. Format-declared counts must not be used as the input length.
Sourcepub fn read_root(
reader: &mut dyn ReadSeek,
arena: &'a DecodeArena,
policy: &DecodePolicy,
container_only: bool,
) -> Result<(Self, View<'a>), CodecError>
pub fn read_root( reader: &mut dyn ReadSeek, arena: &'a DecodeArena, policy: &DecodePolicy, container_only: bool, ) -> Result<(Self, View<'a>), CodecError>
Reads the root input under max_input_bytes, copies it into the arena,
registers the root space, establishes input-proportional allowances,
and returns the context and root view.
Sourcepub fn from_root_bytes(
bytes: &'a [u8],
arena: &'a DecodeArena,
policy: &DecodePolicy,
) -> Result<(Self, View<'a>), CodecError>
pub fn from_root_bytes( bytes: &'a [u8], arena: &'a DecodeArena, policy: &DecodePolicy, ) -> Result<(Self, View<'a>), CodecError>
Builds a context over caller-owned root bytes, for fuzz targets and tests. The arena still backs any expansions produced during decode.
Sourcepub fn from_root_bytes_limit(
bytes: &'a [u8],
arena: &'a DecodeArena,
policy: &DecodePolicy,
) -> Result<(Self, View<'a>), ResourceLimit>
pub fn from_root_bytes_limit( bytes: &'a [u8], arena: &'a DecodeArena, policy: &DecodePolicy, ) -> Result<(Self, View<'a>), ResourceLimit>
Builds a root context with a resource-only refusal channel.
Sourcepub fn policy(&self) -> &DecodePolicy
pub fn policy(&self) -> &DecodePolicy
Returns the decode policy in force.
Sourcepub fn container_only(&self) -> bool
pub fn container_only(&self) -> bool
Returns whether the caller requested container-only decoding.
Sourcepub fn reserve_scoped(
&self,
bytes: u64,
operation: &'static str,
) -> Result<ScopedReservation<'_>, CodecError>
pub fn reserve_scoped( &self, bytes: u64, operation: &'static str, ) -> Result<ScopedReservation<'_>, CodecError>
Reserves bytes held by a temporary materialization.
Sourcepub fn try_materialized<T>(
&self,
bytes: u64,
operation: &'static str,
allocate: impl FnOnce() -> Result<T, TryReserveError>,
) -> Result<(ScopedReservation<'_>, T), CodecError>
pub fn try_materialized<T>( &self, bytes: u64, operation: &'static str, allocate: impl FnOnce() -> Result<T, TryReserveError>, ) -> Result<(ScopedReservation<'_>, T), CodecError>
Admits a temporary byte allocation and holds its reservation until released.
Sourcepub fn reserve_scoped_limit(
&self,
bytes: u64,
operation: &'static str,
) -> Result<ScopedReservation<'_>, ResourceLimit>
pub fn reserve_scoped_limit( &self, bytes: u64, operation: &'static str, ) -> Result<ScopedReservation<'_>, ResourceLimit>
Reserves temporary bytes and returns the typed resource refusal.
Sourcepub fn charge_retained(
&self,
bytes: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_retained( &self, bytes: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges bytes retained for the remainder of this session.
Sourcepub fn charge_retained_limit(
&self,
bytes: u64,
operation: &'static str,
) -> Result<(), ResourceLimit>
pub fn charge_retained_limit( &self, bytes: u64, operation: &'static str, ) -> Result<(), ResourceLimit>
Charge retained storage with a resource-only refusal channel.
Sourcepub fn with_scoped_storage<T, E: From<CodecError>>(
&self,
operation: &'static str,
build: impl FnOnce() -> Result<T, E>,
) -> Result<(T, ScopedReservation<'_>), E>
pub fn with_scoped_storage<T, E: From<CodecError>>( &self, operation: &'static str, build: impl FnOnce() -> Result<T, E>, ) -> Result<(T, ScopedReservation<'_>), E>
Charges storage created by the closure as temporary until its reservation is dropped.
Sourcepub fn copy_retained_text_limit(
&self,
text: &str,
operation: &'static str,
) -> Result<String, ResourceLimit>
pub fn copy_retained_text_limit( &self, text: &str, operation: &'static str, ) -> Result<String, ResourceLimit>
Copies admitted text into retained storage with a typed resource refusal.
Sourcepub fn copy_retained_text(
&self,
text: &str,
operation: &'static str,
) -> Result<String, CodecError>
pub fn copy_retained_text( &self, text: &str, operation: &'static str, ) -> Result<String, CodecError>
Copies admitted text into session-retained storage.
Sourcepub fn copy_retained(
&self,
bytes: &[u8],
operation: &'static str,
) -> Result<Vec<u8>, CodecError>
pub fn copy_retained( &self, bytes: &[u8], operation: &'static str, ) -> Result<Vec<u8>, CodecError>
Copies bytes into session-retained storage after charging and reserving safely.
Sourcepub fn try_reserve_retained_text(
&self,
text: &mut String,
additional: usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn try_reserve_retained_text( &self, text: &mut String, additional: usize, operation: &'static str, ) -> Result<(), CodecError>
Reserves growth of a session-retained string after charging its bytes.
Sourcepub fn copy_retained_lossy_utf8(
&self,
value: &[u8],
operation: &'static str,
) -> Result<String, CodecError>
pub fn copy_retained_lossy_utf8( &self, value: &[u8], operation: &'static str, ) -> Result<String, CodecError>
Copies source bytes as UTF-8 with replacement characters after charging the exact length of the retained text.
Sourcepub fn alloc_filled<T: Clone>(
&self,
count: usize,
value: T,
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn alloc_filled<T: Clone>( &self, count: usize, value: T, operation: &'static str, ) -> Result<Vec<T>, CodecError>
Allocates count copies of value after charging slots, backing bytes
and fill work, with fallible storage admission.
Prefer this over vec![value; parsed_count] for attacker-influenced sizes.
Sourcepub fn alloc_filled_admitted<T: Clone>(
&self,
count: usize,
value: T,
operation: &'static str,
) -> Result<Vec<T>, CodecError>
pub fn alloc_filled_admitted<T: Clone>( &self, count: usize, value: T, operation: &'static str, ) -> Result<Vec<T>, CodecError>
Allocates count copies of value whose backing bytes the caller has
already admitted, as retained or scoped storage, under its own operation.
Charges collection items and fill work only, so the bytes are admitted
exactly once. The caller must have admitted count * size_of::<T>()
bytes before this call.
Sourcepub fn charge_entities(
&self,
count: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_entities( &self, count: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges admitted entities.
Sourcepub fn admit_entities(
&self,
current: u64,
admitted: &mut u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn admit_entities( &self, current: u64, admitted: &mut u64, operation: &'static str, ) -> Result<(), CodecError>
Charges entities newly present since admitted, then advances admitted.
Codecs call this at admission boundaries so max_entities refuses further
work instead of only reporting after a finished IR is built.
Sourcepub fn charge_collection_items(
&self,
count: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_collection_items( &self, count: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges admitted collection items.
Sourcepub fn try_collection<T>(
&self,
count: usize,
operation: &'static str,
allocate: impl FnOnce() -> Result<T, TryReserveError>,
) -> Result<T, CodecError>
pub fn try_collection<T>( &self, count: usize, operation: &'static str, allocate: impl FnOnce() -> Result<T, TryReserveError>, ) -> Result<T, CodecError>
Charges collection items before a fallible collection allocation.
Sourcepub fn charge_collection_items_limit(
&self,
count: u64,
operation: &'static str,
) -> Result<(), ResourceLimit>
pub fn charge_collection_items_limit( &self, count: u64, operation: &'static str, ) -> Result<(), ResourceLimit>
Charges collection items and returns the typed refusal for resource-only callers.
Sourcepub fn enter_nested(
&self,
operation: &'static str,
) -> Result<DepthGuard<'_>, CodecError>
pub fn enter_nested( &self, operation: &'static str, ) -> Result<DepthGuard<'_>, CodecError>
Enters one recursive nesting level until the returned guard is dropped.
Sourcepub fn enter_nested_limit(
&self,
operation: &'static str,
) -> Result<DepthGuard<'_>, ResourceLimit>
pub fn enter_nested_limit( &self, operation: &'static str, ) -> Result<DepthGuard<'_>, ResourceLimit>
Enters one nesting level with a resource-only refusal.
Sourcepub fn charge_work(
&self,
units: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_work( &self, units: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges session-global algorithm work, fusing on refusal.
Sourcepub fn charge_work_limit(
&self,
units: u64,
operation: &'static str,
) -> Result<(), ResourceLimit>
pub fn charge_work_limit( &self, units: u64, operation: &'static str, ) -> Result<(), ResourceLimit>
Charges work with a resource-only refusal channel.
Sourcepub fn stable_sort_by<T>(
&self,
values: &mut [T],
compare: impl FnMut(&T, &T) -> Ordering,
key_bytes: impl Fn(&T) -> usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn stable_sort_by<T>( &self, values: &mut [T], compare: impl FnMut(&T, &T) -> Ordering, key_bytes: impl Fn(&T) -> usize, operation: &'static str, ) -> Result<(), CodecError>
Sort admitted values stably using fallible index scratch.
key_bytes states the key bytes a comparison can read from each value.
Equal values retain input order. Values move in place without cloning children.
Sourcepub fn resource_refusal(&self) -> Option<ResourceLimit>
pub fn resource_refusal(&self) -> Option<ResourceLimit>
Returns the resource refusal that has fused this decode session.
Sourcepub fn refuse_codec_limit(
&self,
operation: &'static str,
limit: u64,
requested: u64,
) -> CodecError
pub fn refuse_codec_limit( &self, operation: &'static str, limit: u64, requested: u64, ) -> CodecError
Permanently refuses a codec-local resource request.
Sourcepub fn work_budget(&self, local_limit: u64) -> WorkBudget<'_>
pub fn work_budget(&self, local_limit: u64) -> WorkBudget<'_>
Creates a local work slice that also draws from the session allowance.
Sourcepub fn begin_expand(
&self,
spec: ExpandSpec,
) -> Result<ExpandWriter<'_, 'a>, CodecError>
pub fn begin_expand( &self, spec: ExpandSpec, ) -> Result<ExpandWriter<'_, 'a>, CodecError>
Begins an expansion whose output is charged incrementally and becomes available only after successful finalization.
Sourcepub fn concat_views(&self, inputs: &[View<'_>]) -> Result<View<'a>, CodecError>
pub fn concat_views(&self, inputs: &[View<'_>]) -> Result<View<'a>, CodecError>
Copies several input extents into one derived view.
Sourcepub fn concat_retained(
&self,
inputs: &[Vec<u8>],
operation: &'static str,
) -> Result<Vec<u8>, CodecError>
pub fn concat_retained( &self, inputs: &[Vec<u8>], operation: &'static str, ) -> Result<Vec<u8>, CodecError>
Concatenates owned chunks into one retained buffer without an arena copy.
Sourcepub fn register_slice<'v>(
&self,
parent: View<'v>,
range: ByteRange,
) -> Result<View<'v>, CodecError>
pub fn register_slice<'v>( &self, parent: View<'v>, range: ByteRange, ) -> Result<View<'v>, CodecError>
Registers a stored (uncompressed) child range as a space that borrows the parent bytes without copying.
range is expressed in the parent view’s own space coordinates and must
lie within the parent window; a range that escapes the parent is refused
here, at the request site, exactly as View::child refuses. No bytes
are copied. It is the archive-entry counterpart of DecodeContext::begin_expand —
stored ZIP entries take this path, compressed ones take the expander.
Registration still refuses on a fused context so a stored entry cannot be
admitted after a refusal.
Sourcepub fn finish_session(self) -> Result<(), CodecError>
pub fn finish_session(self) -> Result<(), CodecError>
Closes a decode or inspection session, returning a fused resource error even when codec code swallowed the charge that caused it.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn inflate_probe(
&self,
source: View<'_>,
cap: usize,
zlib: bool,
) -> Result<Option<(Vec<u8>, ScopedReservation<'_>)>, CodecError>
pub fn inflate_probe( &self, source: View<'_>, cap: usize, zlib: bool, ) -> Result<Option<(Vec<u8>, ScopedReservation<'_>)>, CodecError>
Inflates one raw or zlib member up to cap. An oversized or malformed
member supplies no evidence. Resource refusals remain typed.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn read_input_prefix(
&self,
reader: &mut dyn Read,
length: usize,
) -> Result<Vec<u8>, CodecError>
pub fn read_input_prefix( &self, reader: &mut dyn Read, length: usize, ) -> Result<Vec<u8>, CodecError>
Reads at most length bytes and admits each copied byte before growth.
Input storage is governed by the input-byte dimension.
Sourcepub fn extend_input_prefix(
&self,
reader: &mut dyn Read,
bytes: &mut Vec<u8>,
length: usize,
) -> Result<(), CodecError>
pub fn extend_input_prefix( &self, reader: &mut dyn Read, bytes: &mut Vec<u8>, length: usize, ) -> Result<(), CodecError>
Extends admitted input storage up to a total bounded length.
Sourcepub fn complete_input(
&self,
reader: &mut dyn Read,
bytes: &mut Vec<u8>,
) -> Result<(), CodecError>
pub fn complete_input( &self, reader: &mut dyn Read, bytes: &mut Vec<u8>, ) -> Result<(), CodecError>
Acquires the remaining input without reading or charging the prefix twice.
Sourcepub fn refuse_input_limit(
&self,
additional: u64,
operation: &'static str,
) -> CodecError
pub fn refuse_input_limit( &self, additional: u64, operation: &'static str, ) -> CodecError
Raises a typed input-byte refusal without changing its dimension.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn sort_unstable_by<T>(
&self,
values: &mut [T],
compare: impl FnMut(&T, &T) -> Ordering,
key_bytes: impl Fn(&T) -> usize,
operation: &'static str,
) -> Result<(), CodecError>
pub fn sort_unstable_by<T>( &self, values: &mut [T], compare: impl FnMut(&T, &T) -> Ordering, key_bytes: impl Fn(&T) -> usize, operation: &'static str, ) -> Result<(), CodecError>
Sorts admitted values in place without allocating scratch.
key_bytes states the external bytes a comparison can read from each value.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn parse_xml<'input>(
&self,
text: &'input str,
operation: &'static str,
) -> Result<AdmittedXml<'input, '_>, CodecError>
pub fn parse_xml<'input>( &self, text: &'input str, operation: &'static str, ) -> Result<AdmittedXml<'input, '_>, CodecError>
Admits roxmltree 0.21.1 storage before parsing with DTD disabled. For N = 2 * ‘<’ + 2, A = ‘=’ and S = distinct raw namespace bindings + 1, growing vectors reserve 2 * count + their minimum capacity. Storage covers nodes, permanent and temporary attributes (minimum 16), namespace records and sorted indices. Namespace tree-order slots sum visible bindings at elements with declarations; other elements reuse their parent’s range. Index storage includes old and new allocations during vector growth. Node-sized scratch includes awaiting-subtree IDs, parent prefixes and text Cows. Eight input lengths cover normalization buffers, joined text, shared strings and transient copies; 32 bytes per string cover Arc headers. The fixed 1024 bytes cover initial scratch capacities and parser state. Work covers the scan, parser scans and quadratic attribute/namespace comparisons, including string comparisons and namespace insertion. Attribute comparisons use each tag’s name bytes and attribute count. Namespace work covers prefix lookups, expanded attribute names, inheritance only at tags with declarations, and sorted namespace insertion. Text outside tags and ordinary attribute values pay only scanning/normalization work. Temporary node-ID, prefix, text, attribute and namespace-index slots are admitted separately.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn parse_json_value(
&self,
text: &str,
operation: &'static str,
) -> Result<(Value, ScopedReservation<'_>), CodecError>
pub fn parse_json_value( &self, text: &str, operation: &'static str, ) -> Result<(Value, ScopedReservation<'_>), CodecError>
Parses a value tree under collection, work, scoped storage and depth
admission. Keep the returned reservation alive with the returned Value.
serde_json’s own 128-level recursion ceiling also applies.
Sourcepub fn parse_json<T: DeserializeOwned>(
&self,
text: &str,
operation: &'static str,
) -> Result<T, CodecError>
pub fn parse_json<T: DeserializeOwned>( &self, text: &str, operation: &'static str, ) -> Result<T, CodecError>
Parses types with derived Deserialize: structs, enums, vectors, maps,
strings and scalars. Custom allocating deserializers are outside this
bound. The retained typed result is admitted as twice the value-tree
storage plus size_of::<T>(); conversion charges one work unit per value.
Source validation with the derived deserializer preserves duplicate-field
errors that Value maps erase. Its temporary result has a separate scoped
admission of twice the tree bytes plus size_of::<T>(); scan and conversion
work are charged before validation. Typed trees use ordinary map members
rather than Value’s private raw-value carrier. The admission remains live.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn unique_index<K: Eq + Hash, V>(
&self,
entries: impl IntoIterator<Item = (K, V)>,
key_work: impl Fn(&K) -> Result<u64, CodecError>,
operation: &'static str,
) -> Result<(HashMap<K, Option<V>>, ScopedReservation<'_>), CodecError>
pub fn unique_index<K: Eq + Hash, V>( &self, entries: impl IntoIterator<Item = (K, V)>, key_work: impl Fn(&K) -> Result<u64, CodecError>, operation: &'static str, ) -> Result<(HashMap<K, Option<V>>, ScopedReservation<'_>), CodecError>
Builds a scoped table. Repeated keys become tombstones until the final in-place removal, so a third occurrence cannot restore a duplicate. Surviving values are Some; no second table is allocated.
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn utf16le_text(
&self,
bytes: &[u8],
units: usize,
trim_nul: bool,
operation: &'static str,
) -> Result<String, CodecError>
pub fn utf16le_text( &self, bytes: &[u8], units: usize, trim_nul: bool, operation: &'static str, ) -> Result<String, CodecError>
Validates a UTF-16LE window and retains its exact UTF-8 text size.
Sourcepub fn utf16le_scoped_text<'ctx>(
&'ctx self,
bytes: &[u8],
units: usize,
trim_nul: bool,
operation: &'static str,
) -> Result<(String, ScopedReservation<'ctx>), CodecError>
pub fn utf16le_scoped_text<'ctx>( &'ctx self, bytes: &[u8], units: usize, trim_nul: bool, operation: &'static str, ) -> Result<(String, ScopedReservation<'ctx>), CodecError>
Decodes strict UTF-16LE into storage held by a scoped reservation.
Sourcepub fn utf16le_lossy_text(
&self,
bytes: &[u8],
units: usize,
trim_nul: bool,
operation: &'static str,
) -> Result<String, CodecError>
pub fn utf16le_lossy_text( &self, bytes: &[u8], units: usize, trim_nul: bool, operation: &'static str, ) -> Result<String, CodecError>
Retains exact UTF-8 text while replacing unpaired surrogates with U+FFFD.
Sourcepub fn utf16le_lossy_scoped_text<'ctx>(
&'ctx self,
bytes: &[u8],
units: usize,
trim_nul: bool,
operation: &'static str,
) -> Result<(String, ScopedReservation<'ctx>), CodecError>
pub fn utf16le_lossy_scoped_text<'ctx>( &'ctx self, bytes: &[u8], units: usize, trim_nul: bool, operation: &'static str, ) -> Result<(String, ScopedReservation<'ctx>), CodecError>
Holds replacement UTF-8 text in an exact-byte scoped reservation.
Source§impl<'input> DecodeContext<'input>
impl<'input> DecodeContext<'input>
Sourcepub fn open_zstd<'ctx>(
&'ctx self,
source: View<'input>,
) -> Result<ZstdDecoder<'ctx, 'input>, CodecError>
pub fn open_zstd<'ctx>( &'ctx self, source: View<'input>, ) -> Result<ZstdDecoder<'ctx, 'input>, CodecError>
Inspects all frame windows before allocating a decoder. The largest frame window must fit the materialized-byte and per-expansion ceilings.