pub struct AstArena {
pub raw: RefCell<HashMap<u32, Rc<RawSelector>>>,
pub optimized: RefCell<HashMap<u32, SharedOptimizedSelector>>,
pub first_parts: RefCell<(u64, HashMap<u32, Option<Rc<[u16]>>>)>,
pub selector_prefixes: RefCell<(u64, HashMap<u32, Rc<[String]>>)>,
pub sources: RefCell<Vec<u32>>,
pub input_lengths: RefCell<HashMap<u32, u32>>,
/* private fields */
}Expand description
Css ast arena: ast nodes and value tokens. Derefs to Arena (typescript extends).
Fields§
§raw: RefCell<HashMap<u32, Rc<RawSelector>>>raw selector (minification cache), by rule id split selectors by rule, shared: a read does not copy the selector
optimized: RefCell<HashMap<u32, SharedOptimizedSelector>>optimized selector (minification cache), by rule id
first_parts: RefCell<(u64, HashMap<u32, Option<Rc<[u16]>>>)>first part of the first selector of a selector string (minification cache), by string id: the string epoch the
ids belong to, then the code units (None when the first selector is empty)
selector_prefixes: RefCell<(u64, HashMap<u32, Rc<[String]>>)>vendor prefixes of a selector string (minification cache), by string id, see first_parts
sources: RefCell<Vec<u32>>source ids. spans store the index in this table (8 bits)
input_lengths: RefCell<HashMap<u32, u32>>length of the css parsed into a stylesheet, by stylesheet id
Implementations§
Source§impl AstArena
impl AstArena
a shared arena: AstArena::rc returns its handle
Sourcepub fn register(arena: &Rc<Self>)
pub fn register(arena: &Rc<Self>)
register the shared handle of an arena (an arena created by Rc::new)
pub fn new(size: usize) -> Self
pub fn release(&self, id: Option<u32>, deep: bool)
pub fn compact(&self, errors: Option<&mut [ErrorDescription]>) -> Vec<u32>
pub fn trim(&self, errors: Option<&mut [ErrorDescription]>) -> Vec<u32>
pub fn is_invalid(&self, id: u32) -> bool
Sourcepub fn source_index(&self, src_id: u32) -> u32
pub fn source_index(&self, src_id: u32) -> u32
index of a source id in the sources table
Sourcepub fn set_location(
&self,
id: u32,
src_id: Option<u32>,
sta: Option<u32>,
end: Option<u32>,
)
pub fn set_location( &self, id: u32, src_id: Option<u32>, sta: Option<u32>, end: Option<u32>, )
set the source location. None for both the source and the start drops the location
Sourcepub fn set_token_location(&self, id: u32, source_index: u32, sta: u32, end: u32)
pub fn set_token_location(&self, id: u32, source_index: u32, sta: u32, end: u32)
set the location of a token from the tokenizer values
Sourcepub fn copy_location(&self, id: u32, source: u32)
pub fn copy_location(&self, id: u32, source: u32)
copy the source location of another node
Sourcepub fn span_location(&self, id: u32, start: u32, end: u32)
pub fn span_location(&self, id: u32, start: u32, end: u32)
set the location from the start of a node to the end of another one
pub fn has_location(&self, id: u32) -> bool
Sourcepub fn get_location(&self, id: u32) -> Option<SourceLocation>
pub fn get_location(&self, id: u32) -> Option<SourceLocation>
source location
Sourcepub fn get_source(&self, id: u32) -> u32
pub fn get_source(&self, id: u32) -> u32
source id of the node location
pub fn create_style_sheet(&self) -> u32
pub fn create_rule( &self, typ: u8, sel: StrOrId<'_>, tokens: Option<&[u32]>, state: u32, errors: Option<Vec<ErrorDescription>>, ) -> u32
pub fn create_at_rule( &self, typ: u8, nam: StrOrId<'_>, val: StrOrId<'_>, block: bool, tokens: Option<&[u32]>, state: u32, errors: Option<Vec<ErrorDescription>>, ) -> u32
pub fn create_declaration( &self, typ: u8, nam: StrOrId<'_>, val: Option<&[u32]>, state: u32, errors: Option<Vec<ErrorDescription>>, ) -> u32
pub fn create_comment(&self, typ: u8, val: StrOrId<'_>) -> u32
Sourcepub fn create_token(
&self,
typ: u8,
val: TokenValue<'_>,
unit: Option<&str>,
) -> u32
pub fn create_token( &self, typ: u8, val: TokenValue<'_>, unit: Option<&str>, ) -> u32
allocate a token. string values are interned, numeric values are stored in the numeric_value column
Sourcepub fn create_str_token(&self, typ: u8, val: &str) -> u32
pub fn create_str_token(&self, typ: u8, val: &str) -> u32
allocate a token with a string value
Sourcepub fn create_num_token(&self, typ: u8, val: f64, unit: Option<&str>) -> u32
pub fn create_num_token(&self, typ: u8, val: f64, unit: Option<&str>) -> u32
allocate a token with a numeric value
Sourcepub fn create_color(&self, val: &str, kin: u8, tokens: Option<&[u32]>) -> u32
pub fn create_color(&self, val: &str, kin: u8, tokens: Option<&[u32]>) -> u32
allocate a color token
Sourcepub fn create_function(
&self,
typ: u8,
name: &str,
tokens: Option<&[u32]>,
) -> u32
pub fn create_function( &self, typ: u8, name: &str, tokens: Option<&[u32]>, ) -> u32
allocate a function token
Sourcepub fn create_list(&self, typ: u8, tokens: Option<&[u32]>) -> u32
pub fn create_list(&self, typ: u8, tokens: Option<&[u32]>) -> u32
allocate a list token (parens, attribute, wrapped values, …)
Sourcepub fn create_binary_expression(&self, op: u8, l: u32, r: u32) -> u32
pub fn create_binary_expression(&self, op: u8, l: u32, r: u32) -> u32
allocate a binary expression token. the operator is stored in the numeric_value column
Sourcepub fn create_fraction(&self, l: u32, r: u32) -> u32
pub fn create_fraction(&self, l: u32, r: u32) -> u32
allocate a fraction token
Sourcepub fn has_fraction(&self, id: u32) -> bool
pub fn has_fraction(&self, id: u32) -> bool
true if the numeric token value is a fraction
Sourcepub fn get_fraction(&self, id: u32) -> u32
pub fn get_fraction(&self, id: u32) -> u32
fraction token of a numeric token
Sourcepub fn set_fraction(&self, id: u32, fraction: Option<u32>)
pub fn set_fraction(&self, id: u32, fraction: Option<u32>)
set the fraction value of a numeric token. the numeric value is set to the fraction value
pub fn numerator(&self, id: u32) -> u32
pub fn denominator(&self, id: u32) -> u32
Sourcepub fn set_unit_string(&self, id: u32, unit: Option<&str>)
pub fn set_unit_string(&self, id: u32, unit: Option<&str>)
set the unit of a token
Sourcepub fn is_numeric(&self, id: u32) -> bool
pub fn is_numeric(&self, id: u32) -> bool
true if the token is a numeric token
Sourcepub fn replace_token(&self, id: u32, tokens: &[u32])
pub fn replace_token(&self, id: u32, tokens: &[u32])
replace a token by other tokens in its parent token list
Sourcepub fn take(&self, token: u32) -> u32
pub fn take(&self, token: u32) -> u32
a token that can be attached to a new parent: the token itself when it is detached, a deep clone otherwise
Sourcepub fn copy_token(&self, target: u32, source: u32)
pub fn copy_token(&self, target: u32, source: u32)
copy the data columns of a token
Sourcepub fn reset_token(
&self,
id: u32,
typ: u8,
val: TokenValue<'_>,
unit: Option<&str>,
)
pub fn reset_token( &self, id: u32, typ: u8, val: TokenValue<'_>, unit: Option<&str>, )
reset a token to a new type. the values, the token list and the fields are dropped
Sourcepub fn from_object(&self, node: &Plain) -> u32
pub fn from_object(&self, node: &Plain) -> u32
import a plain object (PlainAstNode / PlainToken). numbers in chi, val, l, … are node ids
Sourcepub fn to_plain_object(&self, id: u32) -> Plain
pub fn to_plain_object(&self, id: u32) -> Plain
export a node or a token as a plain object (deep copy)
Sourcepub fn token_to_object(&self, id: u32) -> Plain
pub fn token_to_object(&self, id: u32) -> Plain
export a token as a plain object (deep copy)
Sourcepub fn clone_node(&self, id: u32) -> u32
pub fn clone_node(&self, id: u32) -> u32
copy the data of a node (type, strings, values, flags, location, errors)
Sourcepub fn clone_node_deep(
&self,
id: u32,
deep: bool,
clone_map: Option<&mut HashMap<u32, u32>>,
) -> u32
pub fn clone_node_deep( &self, id: u32, deep: bool, clone_map: Option<&mut HashMap<u32, u32>>, ) -> u32
copy a node or a token (clone(id, deep, cloneMap)). the tokens of a node are copied, its children are copied
with deep. the values of a declaration are copied with deep
Sourcepub fn import(&self, source: &AstArena, id: u32, deep: bool) -> u32
pub fn import(&self, source: &AstArena, id: u32, deep: bool) -> u32
copy a node or a token of another arena into this arena
Sourcepub fn index_of(&self, id: u32) -> i32
pub fn index_of(&self, id: u32) -> i32
index of a child in its parent’s children (or tokens) list
Sourcepub fn insert_before(&self, reference: u32, nodes: &[u32])
pub fn insert_before(&self, reference: u32, nodes: &[u32])
insert nodes before a child
Sourcepub fn insert_after(&self, reference: u32, nodes: &[u32])
pub fn insert_after(&self, reference: u32, nodes: &[u32])
insert nodes after a child
Sourcepub fn prepend_children(&self, id: u32, nodes: &[u32])
pub fn prepend_children(&self, id: u32, nodes: &[u32])
prepend children
Sourcepub fn replace_child(&self, id: u32, nodes: &[u32])
pub fn replace_child(&self, id: u32, nodes: &[u32])
replace a child with other nodes. the node itself may be part of the replacement
pub fn has_children(&self, id: u32) -> bool
Sourcepub fn get_selector(&self, id: u32) -> SharedStr
pub fn get_selector(&self, id: u32) -> SharedStr
rule selector
pub fn set_selector(&self, id: u32, sel: &str)
pub fn set_name_string(&self, id: u32, nam: &str)
pub fn set_value_string(&self, id: u32, val: &str)
Sourcepub fn expand(&self, ast: u32) -> u32
pub fn expand(&self, ast: u32) -> u32
expand the css nesting rules of a stylesheet, a rule or an at-rule, in place
Sourcepub fn replace_compound(&self, input: &str, replace: &str) -> String
pub fn replace_compound(&self, input: &str, replace: &str) -> String
replace the nesting selector ‘&’ of a selector
Sourcepub fn export_properties(&self) -> ArenaProperties
pub fn export_properties(&self) -> ArenaProperties
properties of the arena
Sourcepub fn import_properties(
&self,
properties: &ArenaProperties,
transferables: ArenaTransferables,
)
pub fn import_properties( &self, properties: &ArenaProperties, transferables: ArenaTransferables, )
initialize the arena from exported properties and column buffers
Sourcepub fn expand_rule(&self, node: u32, parent: u32, before: u32)
pub fn expand_rule(&self, node: u32, parent: u32, before: u32)
expand a rule: the nested rules and at-rules are moved out of the rule, into parent before before. the rule
is detached when it has no children left
Sourcepub fn replace_compound_literal(&self, selector: &str, replace: &str) -> String
pub fn replace_compound_literal(&self, selector: &str, replace: &str) -> String
(sic) port of replaceCompoundLiteral(): the tokens are "" followed by "&", "" per & of the selector,
sorted so that the & come last, then the & are replaced
Methods from Deref<Target = Arena>§
pub fn set_current(&self, current: u32)
Sourcepub fn generation(&self) -> u32
pub fn generation(&self) -> u32
incremented when the columns are reallocated
Sourcepub fn generation_ptr(&self) -> *const u32
pub fn generation_ptr(&self) -> *const u32
address of the generation counter: the javascript views read it to detect a growth of the columns
Sourcepub fn column_raw(&self, index: u32) -> (*const u8, usize)
pub fn column_raw(&self, index: u32) -> (*const u8, usize)
pointer and length (in elements) of a column, by index of arenaColumns. the column views of javascript
Sourcepub fn transferred(&self) -> bool
pub fn transferred(&self) -> bool
true when the column buffers have been transferred: the arena can no longer be used
pub fn allocate(&self) -> u32
Sourcepub fn recycle(&self, id: u32)
pub fn recycle(&self, id: u32)
recycle a detached leaf node that is no longer referenced: its id is reused by the next allocation
Sourcepub fn intern_string(&self, str: &str) -> u32
pub fn intern_string(&self, str: &str) -> u32
intern a string, returns its id
intern a shared string: a shared Rc<str> is not copied
Sourcepub fn intern_range(
&self,
codes: &CodeUnits,
start: usize,
end: usize,
source: i32,
) -> u32
pub fn intern_range( &self, codes: &CodeUnits, start: usize, end: usize, source: i32, ) -> u32
intern a range of code units of a source (or of the canonical text / the pool, see StringSource)
Sourcepub fn intern_units(&self, codes: &[u16]) -> u32
pub fn intern_units(&self, codes: &[u16]) -> u32
intern utf-16 code units
Sourcepub fn intern_canonical(&self, start: u32, end: u32) -> u32
pub fn intern_canonical(&self, start: u32, end: u32) -> u32
intern a range of the canonical text
Sourcepub fn set_source_text(&self, source: usize, codes: CodeUnits)
pub fn set_source_text(&self, source: usize, codes: CodeUnits)
set the code units of a source: the strings interned from the source are ranges of it
pub fn release_source_codes(&self, source: usize)
Sourcepub fn source_text(&self, source: usize) -> Option<CodeUnits>
pub fn source_text(&self, source: usize) -> Option<CodeUnits>
code units of a source
Sourcepub fn string_id(&self, str: &str) -> i32
pub fn string_id(&self, str: &str) -> i32
id of an interned string, -1 when the string is not interned
pub fn string_length(&self, id: u32) -> usize
pub fn string_code_at(&self, id: u32, index: usize) -> u32
pub fn string_index_of(&self, id: u32, code: u32) -> isize
pub fn string_equals(&self, id: u32, str: &str) -> bool
pub fn string_equals_ignore_case(&self, id: u32, str: &str) -> bool
pub fn string_starts_with(&self, id: u32, str: &str) -> bool
Sourcepub fn lower_string_id(&self, id: u32) -> u32
pub fn lower_string_id(&self, id: u32) -> u32
id of the lowercase version of an interned string
Sourcepub fn copy_string_ascii(&self, id: u32, target: &mut Vec<u8>) -> isize
pub fn copy_string_ascii(&self, id: u32, target: &mut Vec<u8>) -> isize
append an interned string to a byte buffer when it is ascii. -1 when it is not ascii
Sourcepub fn string_flag(
&self,
id: u32,
flag: StringFlag,
compute: impl FnOnce(&str) -> bool,
) -> bool
pub fn string_flag( &self, id: u32, flag: StringFlag, compute: impl FnOnce(&str) -> bool, ) -> bool
a boolean property of an interned string, computed once per string id
Sourcepub fn string_flag_id(
&self,
id: u32,
flag: StringFlag,
compute: impl FnOnce(u32) -> bool,
) -> bool
pub fn string_flag_id( &self, id: u32, flag: StringFlag, compute: impl FnOnce(u32) -> bool, ) -> bool
a boolean property of an interned string, computed once per string id from the id
Sourcepub fn string_derived<T: Clone + 'static>(
&self,
id: u32,
slot: StringDerived,
compute: impl FnOnce(u32) -> T,
) -> T
pub fn string_derived<T: Clone + 'static>( &self, id: u32, slot: StringDerived, compute: impl FnOnce(u32) -> T, ) -> T
a value derived from an interned string, computed once per string id
Sourcepub fn copy_string(&self, id: u32, target: &mut Vec<u16>) -> usize
pub fn copy_string(&self, id: u32, target: &mut Vec<u16>) -> usize
append the code units of an interned string to a buffer
Sourcepub fn append_string<'b>(
&self,
builder: &'b mut StringBuilder,
id: u32,
) -> &'b mut StringBuilder
pub fn append_string<'b>( &self, builder: &'b mut StringBuilder, id: u32, ) -> &'b mut StringBuilder
append an interned string to a builder
Sourcepub fn intern_builder(&self, builder: &StringBuilder) -> u32
pub fn intern_builder(&self, builder: &StringBuilder) -> u32
intern the string built by a builder
Sourcepub fn string_epoch(&self) -> u64
pub fn string_epoch(&self) -> u64
identity of the string ids: changed when the strings are renumbered
Sourcepub fn with_string<R>(&self, id: u32, f: impl FnOnce(&str) -> R) -> R
pub fn with_string<R>(&self, id: u32, f: impl FnOnce(&str) -> R) -> R
run a function with an interned string. ascii ranges of a source are borrowed: no string is created
Sourcepub fn resolve_string(&self, id: u32) -> SharedStr
pub fn resolve_string(&self, id: u32) -> SharedStr
the string of an id (created and cached the first time it is read)
pub fn get_type(&self, id: u32) -> u8
Sourcepub fn type_of(&self, id: Option<u32>) -> Option<u8>
pub fn type_of(&self, id: Option<u32>) -> Option<u8>
type of a node or a token. None when the id is None
pub fn set_type(&self, id: u32, typ: u8)
pub fn set_name(&self, id: u32, name_id: u32)
pub fn get_name(&self, id: u32) -> SharedStr
pub fn set_value(&self, id: u32, value_id: u32)
pub fn get_value(&self, id: u32) -> SharedStr
pub fn set_numeric_value(&self, id: u32, value: f64)
pub fn set_unit(&self, id: u32, unit: u32)
pub fn get_unit(&self, id: u32) -> SharedStr
pub fn get_numeric_value(&self, id: u32) -> f64
pub fn set_parent(&self, id: u32, parent: u32)
pub fn get_first_child(&self, id: u32) -> u32
pub fn get_next_sibling(&self, id: u32) -> u32
pub fn get_previous_sibling(&self, id: u32) -> u32
pub fn get_first_token(&self, id: u32) -> u32
pub fn get_last_token(&self, id: u32) -> u32
Sourcepub fn get_capacity(&self) -> usize
pub fn get_capacity(&self) -> usize
number of nodes the columns can hold
pub fn get_last_id(&self) -> u32
pub fn get_string_count(&self) -> u32
Sourcepub fn set_first_child(&self, id: u32, first_child_id: u32)
pub fn set_first_child(&self, id: u32, first_child_id: u32)
replace the first child
pub fn get_last_child(&self, id: u32) -> u32
Sourcepub fn set_last_child(&self, id: u32, last_child_id: u32)
pub fn set_last_child(&self, id: u32, last_child_id: u32)
replace the last child
Sourcepub fn set_next_sibling(&self, id: u32, next_sibling_id: u32)
pub fn set_next_sibling(&self, id: u32, next_sibling_id: u32)
insert a node after another one
Sourcepub fn set_previous_sibling(&self, id: u32, previous_sibling_id: u32)
pub fn set_previous_sibling(&self, id: u32, previous_sibling_id: u32)
insert a node before another one
Sourcepub fn set_first_token(&self, id: u32, first_token_id: u32)
pub fn set_first_token(&self, id: u32, first_token_id: u32)
replace the first token
pub fn set_color_type(&self, id: u32, color_type: u8)
pub fn get_color_type(&self, id: u32) -> u8
pub fn set_flags(&self, id: u32, flags: u32)
pub fn get_flags(&self, id: u32) -> u32
pub fn has_flags(&self, id: u32, flag: u32) -> bool
Sourcepub fn get_token_at(&self, id: u32, index: u32) -> Option<u32>
pub fn get_token_at(&self, id: u32, index: u32) -> Option<u32>
token at an index of the token list
Sourcepub fn set_child_at(&self, id: u32, index: u32, child: u32)
pub fn set_child_at(&self, id: u32, index: u32, child: u32)
replace the child at an index. the node is appended when the index is out of range
Sourcepub fn field_list(&self, id: u32, field: u32) -> u32
pub fn field_list(&self, id: u32, field: u32) -> u32
list node holding the tokens of a structured token field. created when missing
Sourcepub fn set_field(&self, id: u32, field: u32, tokens: &[u32])
pub fn set_field(&self, id: u32, field: u32, tokens: &[u32])
set the tokens of a structured token field
Sourcepub fn append_field(&self, id: u32, field: u32, tokens: &[u32])
pub fn append_field(&self, id: u32, field: u32, tokens: &[u32])
append tokens to a structured token field
pub fn set_left(&self, id: u32, children: &[u32])
pub fn get_left(&self, id: u32) -> Option<Vec<u32>>
pub fn set_right(&self, id: u32, right: &[u32])
pub fn get_right(&self, id: u32) -> Option<Vec<u32>>
pub fn set_op(&self, id: u32, op: u32)
pub fn get_op(&self, id: u32) -> u32
pub fn set_op2(&self, id: u32, op2: u32)
pub fn get_op2(&self, id: u32) -> u32
pub fn set_span(&self, id: u32, source_id: u32, start: u32, end: u32)
pub fn get_source_id(&self, id: u32) -> u32
pub fn get_span_start(&self, id: u32) -> u32
Sourcepub fn set_span_start(&self, id: u32, start: u32)
pub fn set_span_start(&self, id: u32, start: u32)
(sic: the typescript name is setSpandStart)
pub fn get_span_end(&self, id: u32) -> u32
pub fn set_span_end(&self, id: u32, end: u32)
pub fn get_parent(&self, id: u32) -> u32
Sourcepub fn walk<'f>(
&self,
node: u32,
filter: Option<WalkerFilter<'f>>,
reverse: bool,
) -> NodeWalker<'f>
pub fn walk<'f>( &self, node: u32, filter: Option<WalkerFilter<'f>>, reverse: bool, ) -> NodeWalker<'f>
walk the ast nodes: the node and its descendants, in document order
Sourcepub fn walk_with<'f>(
&self,
node: u32,
options: WalkerOptions<'f>,
) -> NodeWalker<'f>
pub fn walk_with<'f>( &self, node: u32, options: WalkerOptions<'f>, ) -> NodeWalker<'f>
walk the ast nodes with options
Sourcepub fn walk_values<'f>(
&self,
node: u32,
options: WalkerValueOptions<'f>,
reverse: bool,
) -> ValueWalker<'f>
pub fn walk_values<'f>( &self, node: u32, options: WalkerValueOptions<'f>, reverse: bool, ) -> ValueWalker<'f>
walk the value tokens of a node / token and their descendants
Sourcepub fn walk_token_values<'f>(
&self,
tokens: &[u32],
options: WalkerValueOptions<'f>,
reverse: bool,
) -> ValueWalker<'f>
pub fn walk_token_values<'f>( &self, tokens: &[u32], options: WalkerValueOptions<'f>, reverse: bool, ) -> ValueWalker<'f>
walk tokens and their descendants
Sourcepub fn walk_ids(&self, node: u32) -> Vec<u32>
pub fn walk_ids(&self, node: u32) -> Vec<u32>
node ids of a subtree in document order (collected)
Sourcepub fn visit_values(&self, tokens: &[u32], visitor: impl FnMut(&Self, u32))
pub fn visit_values(&self, tokens: &[u32], visitor: impl FnMut(&Self, u32))
call the visitor for the tokens and their children, in the order of Arena::walk_values (the children of a
token are read after the visitor returns)
Sourcepub fn get_value_parent(&self, id: u32) -> u32
pub fn get_value_parent(&self, id: u32) -> u32
parent of a value token: the node / token that owns the token list, or the structured token that owns the field (the field list token is skipped). 0 when the token is detached
Sourcepub fn get_value_owner(&self, id: u32) -> u32
pub fn get_value_owner(&self, id: u32) -> u32
node that owns a value token: the declaration, the rule or the at-rule. 0 when the token is detached
Sourcepub fn find(
&self,
node: u32,
matcher: impl FnMut(&Self, u32) -> bool,
) -> Option<u32>
pub fn find( &self, node: u32, matcher: impl FnMut(&Self, u32) -> bool, ) -> Option<u32>
first match of a subtree, in document order
Sourcepub fn find_all(
&self,
node: u32,
matcher: impl FnMut(&Self, u32) -> bool,
) -> Vec<u32>
pub fn find_all( &self, node: u32, matcher: impl FnMut(&Self, u32) -> bool, ) -> Vec<u32>
all the matches of a subtree, in document order
Sourcepub fn find_last(
&self,
node: u32,
matcher: impl FnMut(&Self, u32) -> bool,
) -> Option<u32>
pub fn find_last( &self, node: u32, matcher: impl FnMut(&Self, u32) -> bool, ) -> Option<u32>
last match of a subtree in document order
Sourcepub fn find_by_value(
&self,
node: u32,
matcher: impl FnMut(&Self, u32) -> bool,
) -> Option<(u32, u32)>
pub fn find_by_value( &self, node: u32, matcher: impl FnMut(&Self, u32) -> bool, ) -> Option<(u32, u32)>
first value token match of a subtree: the node that owns the token and the token
Sourcepub fn find_value(
&self,
node: u32,
matcher: impl FnMut(&Self, u32) -> bool,
) -> Option<u32>
pub fn find_value( &self, node: u32, matcher: impl FnMut(&Self, u32) -> bool, ) -> Option<u32>
first match of a token and its descendants, or of the value tokens of a node
Sourcepub fn sub_tokens(&self, id: u32) -> Vec<u32>
pub fn sub_tokens(&self, id: u32) -> Vec<u32>
direct value tokens of a node or a token: the token list, then the tokens of the structured fields and the child tokens
pub fn find_child( &self, id: u32, predicate: impl FnMut(u32) -> bool, ) -> Option<u32>
Sourcepub fn find_token(
&self,
id: u32,
predicate: impl FnMut(&Self, u32) -> bool,
) -> Option<u32>
pub fn find_token( &self, id: u32, predicate: impl FnMut(&Self, u32) -> bool, ) -> Option<u32>
find a token in the token list
Sourcepub fn siblings(
&self,
id: u32,
filter: Option<&mut dyn FnMut(&Self, u32) -> bool>,
) -> Vec<u32>
pub fn siblings( &self, id: u32, filter: Option<&mut dyn FnMut(&Self, u32) -> bool>, ) -> Vec<u32>
the children of the parent of a node, the node included
Sourcepub fn children_filtered(
&self,
id: u32,
filter: impl FnMut(&Self, u32) -> bool,
) -> Vec<u32>
pub fn children_filtered( &self, id: u32, filter: impl FnMut(&Self, u32) -> bool, ) -> Vec<u32>
child node ids accepted by a filter
Sourcepub fn tokens_filtered(
&self,
id: u32,
filter: impl FnMut(&Self, u32) -> bool,
) -> Vec<u32>
pub fn tokens_filtered( &self, id: u32, filter: impl FnMut(&Self, u32) -> bool, ) -> Vec<u32>
token ids of the token list accepted by a filter
Sourcepub fn token_iter(&self, id: u32) -> impl Iterator<Item = u32> + '_
pub fn token_iter(&self, id: u32) -> impl Iterator<Item = u32> + '_
iterate the token list without allocation. the next token is read before the current one is returned
Sourcepub fn child_iter(&self, id: u32) -> impl Iterator<Item = u32> + '_
pub fn child_iter(&self, id: u32) -> impl Iterator<Item = u32> + '_
iterate the children without allocation. the next child is read before the current one is returned
Sourcepub fn token_count(&self, id: u32) -> u32
pub fn token_count(&self, id: u32) -> u32
number of tokens in the token list
pub fn set_children(&self, id: u32, children: &[u32])
Sourcepub fn set_child_list(&self, id: u32, children: &[u32])
pub fn set_child_list(&self, id: u32, children: &[u32])
replace the children
pub fn set_tokens(&self, id: u32, tokens: &[u32])
Sourcepub fn set_token_list(&self, id: u32, tokens: &[u32])
pub fn set_token_list(&self, id: u32, tokens: &[u32])
replace the token list
Sourcepub fn move_children(&self, from: u32, to: u32, before: u32)
pub fn move_children(&self, from: u32, to: u32, before: u32)
move the children of a node into another node, in order
pub fn append_children(&self, id: u32, children: &[u32])
Sourcepub fn append_child_list(&self, id: u32, children: &[u32])
pub fn append_child_list(&self, id: u32, children: &[u32])
append children
pub fn append_tokens(&self, id: u32, tokens: &[u32])
Sourcepub fn append_token_list(&self, id: u32, tokens: &[u32])
pub fn append_token_list(&self, id: u32, tokens: &[u32])
append tokens
Sourcepub fn append_child(&self, id: u32, child: u32)
pub fn append_child(&self, id: u32, child: u32)
append a single child node
Sourcepub fn append_token(&self, id: u32, token: u32)
pub fn append_token(&self, id: u32, token: u32)
append a single token
Sourcepub fn prepend_tokens(&self, id: u32, tokens: &[u32])
pub fn prepend_tokens(&self, id: u32, tokens: &[u32])
prepend tokens to the token list
Sourcepub fn equals_ignore_case(&self, node: u32, key: &str, string: &str) -> bool
pub fn equals_ignore_case(&self, node: u32, key: &str, string: &str) -> bool
key is “nam” or “val”
Sourcepub fn compact_strings(&self)
pub fn compact_strings(&self)
drop the interned strings that are no longer referenced by any node
Sourcepub fn compact(&self, errors: Option<&mut [ErrorDescription]>) -> Vec<u32>
pub fn compact(&self, errors: Option<&mut [ErrorDescription]>) -> Vec<u32>
drop the nodes that are not reachable from the root and renumber the remaining nodes in document order. the unused strings are dropped too. returns the mapping of the old ids to the new ids (0 when dropped)
Sourcepub fn import_columns(&self, t: ArenaTransferables)
pub fn import_columns(&self, t: ArenaTransferables)
replace the columns
pub fn is_marked(&self, id: u32) -> bool
Sourcepub fn release(&self, id: Option<u32>, deep: bool)
pub fn release(&self, id: Option<u32>, deep: bool)
release nodes: detach them and drop their data. None releases the marked nodes
Sourcepub fn trim(&self, errors: Option<&mut [ErrorDescription]>) -> Vec<u32>
pub fn trim(&self, errors: Option<&mut [ErrorDescription]>) -> Vec<u32>
reclaim the memory: release the marked nodes, then compact
pub fn set_errors(&self, id: u32, errors: Option<Vec<ErrorDescription>>)
pub fn get_errors(&self, id: u32) -> Option<Vec<ErrorDescription>>
Sourcepub fn child_count(&self, id: u32) -> u32
pub fn child_count(&self, id: u32) -> u32
number of children
Sourcepub fn export_properties(&self) -> ArenaProperties
pub fn export_properties(&self) -> ArenaProperties
properties of the arena
Sourcepub fn export_transferables(&self) -> ArenaTransferables
pub fn export_transferables(&self) -> ArenaTransferables
copy of the columns
Sourcepub fn take_transferables(&self) -> ArenaTransferables
pub fn take_transferables(&self) -> ArenaTransferables
move the columns out (transfer): the arena can no longer be used
Sourcepub fn import_properties(
&self,
properties: &ArenaProperties,
transferables: ArenaTransferables,
)
pub fn import_properties( &self, properties: &ArenaProperties, transferables: ArenaTransferables, )
initialize the arena from exported properties and column buffers