pub struct Offset {
pub begin: Cursor,
pub end: Cursor,
}Expand description
Text selection offset. Specifies begin and end offsets to select a range of a text, via two Cursor instances.
The end-point is non-inclusive.
Fields§
§begin: Cursor§end: CursorImplementations§
source§impl Offset
impl Offset
pub fn new(begin: Cursor, end: Cursor) -> Self
sourcepub fn simple(begin: usize, end: usize) -> Self
pub fn simple(begin: usize, end: usize) -> Self
Shortcut constructor to create a simple begin-aligned offset (less boilerplate)
sourcepub fn whole() -> Self
pub fn whole() -> Self
Shortcut constructor to create a constructor that selects everything of the target
sourcepub fn is_simple_or_whole(&self) -> bool
pub fn is_simple_or_whole(&self) -> bool
Returns true if this Offset only uses begin-aligned cursors, or if it selects the whole target
sourcepub fn to_json(&self) -> Result<String, StamError>
pub fn to_json(&self) -> Result<String, StamError>
Writes a datavalue to one STAM JSON string, with appropriate formatting
sourcepub fn to_json_compact(&self) -> Result<String, StamError>
pub fn to_json_compact(&self) -> Result<String, StamError>
Writes a datavalue to one STAM JSON string, without any indentation
pub fn mode(&self) -> OffsetMode
Trait Implementations§
source§impl DataSize for Offset
impl DataSize for Offset
source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
If
true, the type has a heap size that can vary at runtime, depending on the actual value.source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
The amount of space a value of the type always occupies. If
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Estimates the size of heap memory taken up by this value. Read more
source§impl<'de> Deserialize<'de> for Offset
impl<'de> Deserialize<'de> for Offset
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<&Offset> for OffsetMode
impl From<&Offset> for OffsetMode
source§fn from(offset: &Offset) -> OffsetMode
fn from(offset: &Offset) -> OffsetMode
Converts to this type from the input type.
source§impl From<&ResultItem<'_, TextSelection>> for Offset
impl From<&ResultItem<'_, TextSelection>> for Offset
source§fn from(textselection: &ResultItem<'_, TextSelection>) -> Offset
fn from(textselection: &ResultItem<'_, TextSelection>) -> Offset
Converts to this type from the input type.
source§impl From<&ResultTextSelection<'_>> for Offset
impl From<&ResultTextSelection<'_>> for Offset
source§fn from(textselection: &ResultTextSelection<'_>) -> Offset
fn from(textselection: &ResultTextSelection<'_>) -> Offset
Converts to this type from the input type.
source§impl From<&TextSelection> for Offset
impl From<&TextSelection> for Offset
source§fn from(textselection: &TextSelection) -> Offset
fn from(textselection: &TextSelection) -> Offset
Converts to this type from the input type.
source§impl From<TextSelection> for Offset
impl From<TextSelection> for Offset
source§fn from(textselection: TextSelection) -> Offset
fn from(textselection: TextSelection) -> Offset
Converts to this type from the input type.
source§impl PartialEq for Offset
impl PartialEq for Offset
impl StructuralPartialEq for Offset
Auto Trait Implementations§
impl RefUnwindSafe for Offset
impl Send for Offset
impl Sync for Offset
impl Unpin for Offset
impl UnwindSafe for Offset
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more