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 only other whole-document
48 /// string available to them 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.
51 pub matched_texts: Vec<String>,
52 pub count: i64,
53}
54#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
55pub struct ReplaceTextDto {
56 pub query: String,
57 pub replacement: String,
58 pub case_sensitive: bool,
59 pub whole_word: bool,
60 /// See [`FindTextDto::diacritic_sensitive`].
61 pub diacritic_sensitive: bool,
62 /// See [`FindTextDto::language`].
63 pub language: String,
64 pub use_regex: bool,
65 pub replace_all: bool,
66 /// What the replacement text wears where it overwrites formatted prose.
67 ///
68 /// Defaults to the historical behaviour (`InheritPreceding`), which drops the
69 /// formatting under the range — fine for plain text, destructive for a rename that
70 /// lands on a partly-bold name. See [`ReplaceFormatPolicy`].
71 pub format_policy: ReplaceFormatPolicy,
72}
73#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
74pub struct ReplaceResultDto {
75 pub replacements_count: i64,
76 pub skipped_cross_block: i64,
77}
78
79/// An explicit set of ranges to replace, each with its own replacement text.
80///
81/// The three lists are **parallel** and must be the same length: range `i` is
82/// `positions[i] .. positions[i] + lengths[i]`, replaced by `replacements[i]`. Positions
83/// are **char** offsets into the document's search text.
84///
85/// A list of structs is not expressible in a DTO here (every field is a scalar or a list
86/// of scalars — `FindAllResultDto` uses the same parallel-list idiom), so the public API
87/// exposes the typed `ReplaceRange` shape and converts at this boundary.
88#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
89pub struct ReplaceRangesDto {
90 pub positions: Vec<i64>,
91 pub lengths: Vec<i64>,
92 pub replacements: Vec<String>,
93 /// What each replacement wears where it overwrites formatted prose. See
94 /// [`ReplaceFormatPolicy`].
95 pub format_policy: ReplaceFormatPolicy,
96}
97
98#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
99pub struct ReplaceRangesResultDto {
100 pub replacements_count: i64,
101 /// Ranges that straddled a block boundary. A block is the unit an edit is applied to,
102 /// so a range crossing two of them is refused rather than half-applied.
103 pub skipped_cross_block: i64,
104 /// Ranges that overlapped an earlier one. Two edits to the same characters cannot both
105 /// be honoured; the earlier range wins and the later is reported, never silently
106 /// dropped.
107 pub skipped_overlapping: i64,
108}