text_document_search/dtos.rs
1// Generated by Qleany v1.5.1 from feature_dtos.tera
2
3use common::format_runs::ReplaceFormatPolicy;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
7pub struct FindTextDto {
8 pub query: String,
9 pub case_sensitive: bool,
10 pub whole_word: bool,
11 /// `false` (the default) folds diacritics, ligatures and Arabic orthography, so that
12 /// `aurelien` finds `Aurélien`. See `crate::folding`.
13 pub diacritic_sensitive: bool,
14 /// The BCP-47 tag of the text being searched. Only Turkish and Azerbaijani change how
15 /// text *folds*; anything else — including an empty or malformed tag — is untailored.
16 pub language: String,
17 pub use_regex: bool,
18 pub search_backward: bool,
19 pub start_position: i64,
20}
21#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
22pub struct FindResultDto {
23 pub found: bool,
24 pub position: i64,
25 pub length: i64,
26 /// The text that was actually matched. Folding means the query is not it: `cafe` matches
27 /// `café`. Sliced from the text the search ran on, so a caller never has to.
28 pub matched_text: String,
29}
30#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
31pub struct FindAllDto {
32 pub query: String,
33 pub case_sensitive: bool,
34 pub whole_word: bool,
35 /// See [`FindTextDto::diacritic_sensitive`].
36 pub diacritic_sensitive: bool,
37 /// See [`FindTextDto::language`].
38 pub language: String,
39 pub use_regex: bool,
40}
41#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
42pub struct FindAllResultDto {
43 pub positions: Vec<i64>,
44 pub lengths: Vec<i64>,
45 /// The matched **text** of each occurrence, sliced from the document's own search text.
46 ///
47 /// Returned so a caller never has to slice it themselves. The tempting whole-document
48 /// string to slice instead is `to_plain_text`, which is the human-readable view and does
49 /// **not** carry the `U+FFFC` anchor an embedded table occupies — so slicing that with
50 /// these offsets is wrong by two characters per preceding table. (A caller that truly
51 /// needs the sliceable string can ask for [`AddressableTextResultDto`], which shares
52 /// this offset space.)
53 pub matched_texts: Vec<String>,
54 pub count: i64,
55}
56/// The document's **addressable text**: the exact string every document offset is an
57/// index into — `find_all`/`find_text` match positions, `replace_ranges` ranges, a
58/// block's `document_position`, a cursor or selection offset from an editor widget.
59///
60/// Built by the same code path `find_all` uses to build the text it searches
61/// (`build_full_text`), so the two cannot diverge. This is **not** the export view:
62/// an embedded table occupies its `U+FFFC` anchor here (one char plus its `\n`
63/// separator), exactly as the document holds it, where `to_plain_text` omits it.
64#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
65pub struct AddressableTextResultDto {
66 pub text: String,
67}
68
69#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
70pub struct ReplaceTextDto {
71 pub query: String,
72 pub replacement: String,
73 pub case_sensitive: bool,
74 pub whole_word: bool,
75 /// See [`FindTextDto::diacritic_sensitive`].
76 pub diacritic_sensitive: bool,
77 /// See [`FindTextDto::language`].
78 pub language: String,
79 pub use_regex: bool,
80 pub replace_all: bool,
81 /// What the replacement text wears where it overwrites formatted prose.
82 ///
83 /// Defaults to the historical behaviour (`InheritPreceding`), which drops the
84 /// formatting under the range — fine for plain text, destructive for a rename that
85 /// lands on a partly-bold name. See [`ReplaceFormatPolicy`].
86 pub format_policy: ReplaceFormatPolicy,
87}
88#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
89pub struct ReplaceResultDto {
90 pub replacements_count: i64,
91 pub skipped_cross_block: i64,
92}
93
94/// An explicit set of ranges to replace, each with its own replacement text.
95///
96/// The three lists are **parallel** and must be the same length: range `i` is
97/// `positions[i] .. positions[i] + lengths[i]`, replaced by `replacements[i]`. Positions
98/// are **char** offsets into the document's search text.
99///
100/// A list of structs is not expressible in a DTO here (every field is a scalar or a list
101/// of scalars — `FindAllResultDto` uses the same parallel-list idiom), so the public API
102/// exposes the typed `ReplaceRange` shape and converts at this boundary.
103#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
104pub struct ReplaceRangesDto {
105 pub positions: Vec<i64>,
106 pub lengths: Vec<i64>,
107 pub replacements: Vec<String>,
108 /// What each replacement wears where it overwrites formatted prose. See
109 /// [`ReplaceFormatPolicy`].
110 pub format_policy: ReplaceFormatPolicy,
111}
112
113#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
114pub struct ReplaceRangesResultDto {
115 pub replacements_count: i64,
116 /// Ranges that straddled a block boundary. A block is the unit an edit is applied to,
117 /// so a range crossing two of them is refused rather than half-applied.
118 pub skipped_cross_block: i64,
119 /// Ranges that overlapped an earlier one. Two edits to the same characters cannot both
120 /// be honoured; the earlier range wins and the later is reported, never silently
121 /// dropped.
122 pub skipped_overlapping: i64,
123}