pub struct SelectionPlace {
pub item: String,
pub at: Option<usize>,
pub start: Option<usize>,
pub end: Option<usize>,
}Expand description
Where a selection is inside a resource: an item, a caret or a character
range inside one item. Its JSON form is exactly what an action’s place
parameter takes (tilo_resource::Place), so an agent hands it back
unchanged.
Fields§
§item: String§at: Option<usize>§start: Option<usize>§end: Option<usize>Implementations§
Source§impl SelectionPlace
impl SelectionPlace
pub fn caret(item: impl Into<String>, at: usize) -> Self
Sourcepub fn range(item: impl Into<String>, start: usize, end: usize) -> Self
pub fn range(item: impl Into<String>, start: usize, end: usize) -> Self
Characters start..end of item; the bounds are put in order.
Sourcepub fn validated_span(&self) -> Result<SelectionSpan, String>
pub fn validated_span(&self) -> Result<SelectionSpan, String>
Validate this place and return its position inside Self::item:
a whole item, a caret at, or an ordered range start..end.
§Errors
Returns a reason when item is empty, oversized, or holds control
characters, or when at, start, and end do not name one item,
caret, or ordered range.
Trait Implementations§
Source§impl Clone for SelectionPlace
impl Clone for SelectionPlace
Source§impl Debug for SelectionPlace
impl Debug for SelectionPlace
Source§impl<'de> Deserialize<'de> for SelectionPlace
impl<'de> Deserialize<'de> for SelectionPlace
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
impl Eq for SelectionPlace
Source§impl PartialEq for SelectionPlace
impl PartialEq for SelectionPlace
Source§impl Serialize for SelectionPlace
impl Serialize for SelectionPlace
impl StructuralPartialEq for SelectionPlace
Auto Trait Implementations§
impl Forget for SelectionPlace
impl Freeze for SelectionPlace
impl Move for SelectionPlace
impl RefUnwindSafe for SelectionPlace
impl Send for SelectionPlace
impl Sync for SelectionPlace
impl Unpin for SelectionPlace
impl UnsafeUnpin for SelectionPlace
impl UnwindSafe for SelectionPlace
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more