Struct SelectionAnchor
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§
§impl SelectionAnchor
impl SelectionAnchor
pub fn of_text(excerpt: &str) -> SelectionAnchor
pub fn of_text(excerpt: &str) -> SelectionAnchor
An anchor of excerpt alone: what is known of a selection in an app
that publishes no resources, read from the primary selection.
pub fn of_items<I, L>(
items: impl IntoIterator<Item = (I, L)>,
) -> SelectionAnchor
pub fn of_items<I, L>( items: impl IntoIterator<Item = (I, L)>, ) -> SelectionAnchor
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) -> SelectionAnchor
pub fn at(self, place: SelectionPlace) -> SelectionAnchor
pub fn spanning(
self,
region: &str,
ranges: Vec<InteractionTextRange>,
) -> SelectionAnchor
pub fn spanning( self, region: &str, ranges: Vec<InteractionTextRange>, ) -> SelectionAnchor
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.
pub fn spanned_ranges(&self) -> Option<&[InteractionTextRange]>
pub fn spanned_ranges(&self) -> Option<&[InteractionTextRange]>
The block ranges of a selection spanning several blocks
(Self::spanning).
pub fn non_empty(self) -> Option<SelectionAnchor>
pub fn non_empty(self) -> Option<SelectionAnchor>
The anchor, unless it says nothing.
Trait Implementations§
§impl Clone for SelectionAnchor
impl Clone for SelectionAnchor
§fn clone(&self) -> SelectionAnchor
fn clone(&self) -> SelectionAnchor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for SelectionAnchor
impl Debug for SelectionAnchor
§impl Default for SelectionAnchor
impl Default for SelectionAnchor
§fn default() -> SelectionAnchor
fn default() -> SelectionAnchor
§impl<'de> Deserialize<'de> for SelectionAnchor
impl<'de> Deserialize<'de> for SelectionAnchor
§fn deserialize<D>(
deserializer: D,
) -> Result<SelectionAnchor, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SelectionAnchor, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl PartialEq for SelectionAnchor
impl PartialEq for SelectionAnchor
§impl Serialize for SelectionAnchor
impl Serialize for SelectionAnchor
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for SelectionAnchor
impl StructuralPartialEq for SelectionAnchor
Auto Trait Implementations§
impl Freeze 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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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