1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//! AT Protocol rich text facet types.
//!
//! This module provides types for annotating rich text content with semantic
//! meaning, based on the `app.bsky.richtext.facet` lexicon. Facets enable
//! mentions, links, hashtags, and other structured metadata to be attached
//! to specific byte ranges within text content.
//!
//! # Overview
//!
//! Facets consist of:
//! - A byte range (start/end indices in UTF-8 encoded text)
//! - One or more features (mention, link, tag) that apply to that range
//!
//! # Example
//!
//! ```ignore
//! use atproto_record::lexicon::app::bsky::richtext::facet::{Facet, ByteSlice, FacetFeature, Mention};
//!
//! // Create a mention facet for "@alice.bsky.social"
//! let facet = Facet {
//! index: ByteSlice { byte_start: 0, byte_end: 19 },
//! features: vec![
//! FacetFeature::Mention(Mention {
//! did: "did:plc:alice123".to_string(),
//! })
//! ],
//! };
//! ```
use ;
/// Byte range specification for facet features.
///
/// Specifies the sub-string range a facet feature applies to using
/// zero-indexed byte offsets in UTF-8 encoded text. Start index is
/// inclusive, end index is exclusive.
///
/// # Example
///
/// ```ignore
/// use atproto_record::lexicon::app::bsky::richtext::facet::ByteSlice;
///
/// // Represents bytes 0-5 of the text
/// let slice = ByteSlice {
/// byte_start: 0,
/// byte_end: 5,
/// };
/// ```
/// Mention facet feature for referencing another account.
///
/// The text content typically displays a handle with '@' prefix (e.g., "@alice.bsky.social"),
/// but the facet reference must use the account's DID for stable identification.
///
/// # Example
///
/// ```ignore
/// use atproto_record::lexicon::app::bsky::richtext::facet::Mention;
///
/// let mention = Mention {
/// did: "did:plc:alice123".to_string(),
/// };
/// ```
/// Link facet feature for URL references.
///
/// The text content may be simplified or truncated for display purposes,
/// but the facet reference should contain the complete, valid URL.
///
/// # Example
///
/// ```ignore
/// use atproto_record::lexicon::app::bsky::richtext::facet::Link;
///
/// let link = Link {
/// uri: "https://example.com/full/path".to_string(),
/// };
/// ```
/// Tag facet feature for hashtags.
///
/// The text content typically includes a '#' prefix for display,
/// but the facet reference should contain only the tag text without the prefix.
///
/// # Example
///
/// ```ignore
/// use atproto_record::lexicon::app::bsky::richtext::facet::Tag;
///
/// // For text "#atproto", store just "atproto"
/// let tag = Tag {
/// tag: "atproto".to_string(),
/// };
/// ```
/// Discriminated union of facet feature types.
///
/// Represents the different types of semantic annotations that can be
/// applied to text ranges. Each variant corresponds to a specific lexicon
/// type in the `app.bsky.richtext.facet` namespace.
///
/// # Example
///
/// ```ignore
/// use atproto_record::lexicon::app::bsky::richtext::facet::{FacetFeature, Mention, Link, Tag};
///
/// // Create different feature types
/// let mention = FacetFeature::Mention(Mention {
/// did: "did:plc:alice123".to_string(),
/// });
///
/// let link = FacetFeature::Link(Link {
/// uri: "https://example.com".to_string(),
/// });
///
/// let tag = FacetFeature::Tag(Tag {
/// tag: "rust".to_string(),
/// });
/// ```
/// Rich text facet annotation.
///
/// Associates one or more semantic features with a specific byte range
/// within text content. Multiple features can apply to the same range
/// (e.g., a URL that is also a hashtag).
///
/// # Example
///
/// ```ignore
/// use atproto_record::lexicon::app::bsky::richtext::facet::{
/// Facet, ByteSlice, FacetFeature, Mention, Link
/// };
///
/// // Annotate "@alice.bsky.social" at bytes 0-19
/// let facet = Facet {
/// index: ByteSlice { byte_start: 0, byte_end: 19 },
/// features: vec![
/// FacetFeature::Mention(Mention {
/// did: "did:plc:alice123".to_string(),
/// }),
/// ],
/// };
///
/// // Multiple features for the same range
/// let multi_facet = Facet {
/// index: ByteSlice { byte_start: 20, byte_end: 35 },
/// features: vec![
/// FacetFeature::Link(Link {
/// uri: "https://example.com".to_string(),
/// }),
/// FacetFeature::Tag(Tag {
/// tag: "example".to_string(),
/// }),
/// ],
/// };
/// ```