Expand description
Very often we’ll talk about substrings of the plaintext - words, sentences,
etc. A DNMRange
stores start and end point of such a substring and has
a reference to the DNM
.
Fields
start: usize
Offset of the beginning of the range
end: usize
Offset of the end of the range
dnm: &'dnmrange DNM
DNM containing this range
Implementations
sourceimpl<'dnmrange> DNMRange<'dnmrange>
impl<'dnmrange> DNMRange<'dnmrange>
sourcepub fn get_plaintext(&self) -> &'dnmrange str
pub fn get_plaintext(&self) -> &'dnmrange str
Get the plaintext substring corresponding to the range
sourcepub fn get_plaintext_truncated(&self) -> &'dnmrange str
pub fn get_plaintext_truncated(&self) -> &'dnmrange str
Get the plaintext without trailing white spaces
sourcepub fn trim(&self) -> DNMRange<'dnmrange>
pub fn trim(&self) -> DNMRange<'dnmrange>
Returns a DNMRange
with the leading and trailing whitespaces removed
sourcepub fn get_subrange(
&self,
rel_start: usize,
rel_end: usize
) -> DNMRange<'dnmrange>
pub fn get_subrange(
&self,
rel_start: usize,
rel_end: usize
) -> DNMRange<'dnmrange>
returns a subrange, with offsets relative to the beginning of self
sourcepub fn get_subrange_from_byte_offsets(
&self,
rel_start: usize,
rel_end: usize
) -> DNMRange<'dnmrange>
pub fn get_subrange_from_byte_offsets(
&self,
rel_start: usize,
rel_end: usize
) -> DNMRange<'dnmrange>
returns a subrange from a pair of byte offsets (not character offsets, remember, we’re in UTF-8)
sourcepub fn create_arange(from: &str, to: &str) -> String
pub fn create_arange(from: &str, to: &str) -> String
creates an arange from to xpointers
sourcepub fn serialize_offset(
root_node: RoNode,
node: RoNode,
offset: i32,
is_end: bool
) -> String
pub fn serialize_offset(
root_node: RoNode,
node: RoNode,
offset: i32,
is_end: bool
) -> String
Serializes a node and an offset into an xpointer is_end indicates whether the node indicates the end of the interval
sourcepub fn serialize_node(root_node: RoNode, node: RoNode, is_end: bool) -> String
pub fn serialize_node(root_node: RoNode, node: RoNode, is_end: bool) -> String
serializes a node into an xpath expression
sourcepub fn deserialize(
string: &str,
dnm: &'dnmrange DNM,
xpath_context: &Context
) -> DNMRange<'dnmrange>
pub fn deserialize(
string: &str,
dnm: &'dnmrange DNM,
xpath_context: &Context
) -> DNMRange<'dnmrange>
deserializes an xpointer into a DNMRange
. Note that only a very limited subset of xpointers
is supported. Essentially, you should not use it for deserialization of xpointers generated by
any other tool. (TODO: Support a wider range of xpointers)