pub struct AttributedRange {
pub start: usize,
pub end: usize,
pub effects: Vec<TextEffect>,
pub attachment: Option<AttachmentMeta>,
pub emoji_image: bool,
}Expand description
One attribute run of a message’s NSAttributedString
body: a byte range into the Message’s text
plus every attribute applied to it.
A range is a text range when attachment is None and
an attachment range (a \u{FFFC} placeholder for an inline attachment)
when it is Some. Effects, styles, and the inline-emoji hint apply to either
kind. The typedstream attribute dictionary is a flat bag, so an attachment
range can also carry, say, an Animated effect.
Ranges that share a __kIMMessagePartAttributeName index are grouped into one
BubbleComponent::Run. For example, message text with a
Mention like:
let message_text = "What's up, Christopher?";parses into a single run of 3 ranges:
use imessage_database::message_types::text_effects::text_effect::TextEffect;
use imessage_database::tables::messages::models::{AttributedRange, BubbleComponent};
let result = vec![BubbleComponent::Run(vec![
AttributedRange::text(0, 11, vec![TextEffect::Default]), // `What's up, `
AttributedRange::text(11, 22, vec![TextEffect::Mention("+5558675309".to_string())]), // `Christopher`
AttributedRange::text(22, 23, vec![TextEffect::Default]) // `?`
])];Fields§
§start: usizeStart byte index in the message text.
end: usizeEnd byte index in the message text.
effects: Vec<TextEffect>Effects applied to this range.
attachment: Option<AttachmentMeta>Some when this range is a \u{FFFC} placeholder for an attachment.
The attachment’s metadata travels here; effects still apply alongside.
emoji_image: booltrue when the range carries __kIMEmojiImageAttributeName–Apple’s
hint to render the attachment inline–like an emoji (observed on
genmoji, Memoji, and custom sticker ranges).
Implementations§
Source§impl AttributedRange
impl AttributedRange
Sourcepub fn text(start: usize, end: usize, effects: Vec<TextEffect>) -> Self
pub fn text(start: usize, end: usize, effects: Vec<TextEffect>) -> Self
Build a text range (no attachment, no inline-emoji hint) with the specified start index, end index, and text effects.
Sourcepub fn attachment(start: usize, end: usize, meta: AttachmentMeta) -> Self
pub fn attachment(start: usize, end: usize, meta: AttachmentMeta) -> Self
Build an attachment range carrying the given AttachmentMeta, with
no inline-emoji hint.
Sourcepub fn inline_attachment(start: usize, end: usize, meta: AttachmentMeta) -> Self
pub fn inline_attachment(start: usize, end: usize, meta: AttachmentMeta) -> Self
Build an inline-rendered attachment range, one Apple flagged with
__kIMEmojiImageAttributeName to render inline like an emoji (a Memoji,
genmoji, or custom sticker placed amongst text).
Sourcepub fn is_attachment(&self) -> bool
pub fn is_attachment(&self) -> bool
true when this range stands in for an attachment rather than text.
Trait Implementations§
Source§impl Clone for AttributedRange
impl Clone for AttributedRange
Source§fn clone(&self) -> AttributedRange
fn clone(&self) -> AttributedRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AttributedRange
impl Debug for AttributedRange
Source§impl PartialEq for AttributedRange
impl PartialEq for AttributedRange
Source§fn eq(&self, other: &AttributedRange) -> bool
fn eq(&self, other: &AttributedRange) -> bool
self and other values to be equal, and is used by ==.