pub struct SelectionAnchor {
pub place: Option<SelectionPlace>,
pub items: Vec<SelectionPlace>,
pub interaction: Option<InteractionAnchor>,
pub excerpt: Option<String>,
}Expand description
What was selected: where (a place, an app-native anchor, or both) and a
short excerpt of it. Every part is optional; an empty anchor says
nothing and is dropped by Self::non_empty.
Encoded as a JSON object in JSON, and as that object’s JSON text in a
binary format, because an InteractionAnchor reads only from JSON.
Fields§
§place: Option<SelectionPlace>§items: Vec<SelectionPlace>Every item of a selection of several (files in a folder, rows of a
list), each the whole of one item, in the order shown. Empty for a
selection inside one item, which Self::place names.
interaction: Option<InteractionAnchor>§excerpt: Option<String>Implementations§
Source§impl SelectionAnchor
impl SelectionAnchor
Sourcepub fn of_text(excerpt: &str) -> Self
pub fn of_text(excerpt: &str) -> Self
An anchor of excerpt alone: what is known of a selection in an app
that publishes no resources, read from the primary selection.
Sourcepub fn of_items<I, L>(items: impl IntoIterator<Item = (I, L)>) -> Self
pub fn of_items<I, L>(items: impl IntoIterator<Item = (I, L)>) -> Self
A selection of several whole items, each (id, label) in the order
shown: every item named as a place (at most MAX_SELECTED_ITEMS),
and an excerpt listing their labels, counting any beyond that.
pub fn with_excerpt(self, excerpt: &str) -> Self
pub fn at(self, place: SelectionPlace) -> Self
Sourcepub fn spanning(self, region: &str, ranges: Vec<InteractionTextRange>) -> Self
pub fn spanning(self, region: &str, ranges: Vec<InteractionTextRange>) -> Self
The same anchor noting the whole of a selection that spans several
blocks of a text, ranges in document order, of which Self::place
is one block’s part (an action’s place names one block). One range
says nothing more than the place, so it is left out; a long
selection keeps its first crate::interaction::MAX_ANCHOR_ITEMS.
Sourcepub fn spanned_ranges(&self) -> Option<&[InteractionTextRange]>
pub fn spanned_ranges(&self) -> Option<&[InteractionTextRange]>
The block ranges of a selection spanning several blocks
(Self::spanning).
Trait Implementations§
Source§impl Clone for SelectionAnchor
impl Clone for SelectionAnchor
Source§impl Debug for SelectionAnchor
impl Debug for SelectionAnchor
Source§impl Default for SelectionAnchor
impl Default for SelectionAnchor
Source§impl<'de> Deserialize<'de> for SelectionAnchor
impl<'de> Deserialize<'de> for SelectionAnchor
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for SelectionAnchor
Source§impl PartialEq for SelectionAnchor
impl PartialEq for SelectionAnchor
Source§impl Serialize for SelectionAnchor
impl Serialize for SelectionAnchor
impl StructuralPartialEq for SelectionAnchor
Auto Trait Implementations§
impl Forget for SelectionAnchor
impl Freeze for SelectionAnchor
impl Move for SelectionAnchor
impl RefUnwindSafe for SelectionAnchor
impl Send for SelectionAnchor
impl Sync for SelectionAnchor
impl Unpin for SelectionAnchor
impl UnsafeUnpin for SelectionAnchor
impl UnwindSafe for SelectionAnchor
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
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> ⓘ
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> ⓘ
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