#[repr(u32)]
pub enum TextAffinity {
Upstream,
Downstream,
}
Expand description
Whether a TextPosition is visually upstream or downstream of its offset.
For example, when a text position exists at a line break, a single offset has two visual positions, one prior to the line break (at the end of the first line) and one after the line break (at the start of the second line). A text affinity disambiguates between those cases. (Something similar happens with between runs of bidirectional text.)
We do not expect new values to be added to this enum.
Variants§
Upstream
The position has affinity for the upstream side of the text position.
For example, if the offset of the text position is a line break, the position represents the end of the first line.
Downstream
The position has affinity for the downstream side of the text position.
For example, if the offset of the text position is a line break, the position represents the start of the second line.
Implementations§
source§impl TextAffinity
impl TextAffinity
pub fn from_primitive(prim: u32) -> Option<Self>
pub const fn into_primitive(self) -> u32
pub fn is_unknown(&self) -> bool
is_unknown
Trait Implementations§
source§impl Clone for TextAffinity
impl Clone for TextAffinity
source§fn clone(&self) -> TextAffinity
fn clone(&self) -> TextAffinity
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TextAffinity
impl Debug for TextAffinity
source§impl Decodable for TextAffinity
impl Decodable for TextAffinity
source§fn decode(
&mut self,
decoder: &mut Decoder<'_>,
offset: usize
) -> Result<(), Error>
fn decode( &mut self, decoder: &mut Decoder<'_>, offset: usize ) -> Result<(), Error>
self
.
Callers must ensure that offset
is a multiple of
Layout::inline_align
, and that decoder.buf
has room for reading
Layout::inline_size
bytes at offset
. Read moresource§impl Encodable for TextAffinity
impl Encodable for TextAffinity
source§fn encode(
&mut self,
encoder: &mut Encoder<'_, '_>,
offset: usize,
recursion_depth: usize
) -> Result<(), Error>
fn encode( &mut self, encoder: &mut Encoder<'_, '_>, offset: usize, recursion_depth: usize ) -> Result<(), Error>
Handle::INVALID
. Callers must ensure that offset
is a
multiple of Layout::inline_align
, and that encoder.buf
has room for
writing Layout::inline_size
bytes at offset
. Read moresource§impl Hash for TextAffinity
impl Hash for TextAffinity
source§impl Layout for TextAffinity
impl Layout for TextAffinity
source§fn inline_align(context: &Context) -> usize
fn inline_align(context: &Context) -> usize
source§fn inline_size(context: &Context) -> usize
fn inline_size(context: &Context) -> usize
inline_align
.§fn supports_simple_copy() -> boolwhere
Self: Sized,
fn supports_simple_copy() -> boolwhere Self: Sized,
source§impl Ord for TextAffinity
impl Ord for TextAffinity
source§fn cmp(&self, other: &TextAffinity) -> Ordering
fn cmp(&self, other: &TextAffinity) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<TextAffinity> for TextAffinity
impl PartialEq<TextAffinity> for TextAffinity
source§fn eq(&self, other: &TextAffinity) -> bool
fn eq(&self, other: &TextAffinity) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<TextAffinity> for TextAffinity
impl PartialOrd<TextAffinity> for TextAffinity
source§fn partial_cmp(&self, other: &TextAffinity) -> Option<Ordering>
fn partial_cmp(&self, other: &TextAffinity) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for TextAffinity
impl Eq for TextAffinity
impl StructuralEq for TextAffinity
impl StructuralPartialEq for TextAffinity
Auto Trait Implementations§
impl RefUnwindSafe for TextAffinity
impl Send for TextAffinity
impl Sync for TextAffinity
impl Unpin for TextAffinity
impl UnwindSafe for TextAffinity
Blanket Implementations§
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>
§impl<T> LayoutObject for Twhere
T: Layout,
impl<T> LayoutObject for Twhere T: Layout,
§fn inline_align(&self, context: &Context) -> usize
fn inline_align(&self, context: &Context) -> usize
Layout::inline_align
.§fn inline_size(&self, context: &Context) -> usize
fn inline_size(&self, context: &Context) -> usize
Layout::inline_size
.