talon_core/contracts/
accessors.rs1use crate::indexing::{InspectResponse, StatusResponse, SyncResponse};
4use crate::query::{AskResponse, ChangesResponse, MetaResponse, ReadResponse, RelatedResponse};
5use crate::search::SearchResponse;
6
7use super::{TalonResponseData, TalonResponseTrait};
8
9impl TalonResponseTrait for TalonResponseData {
10 fn action(&self) -> &str {
11 match self {
12 Self::Search(_) => "search",
13 Self::Ask(_) => "ask",
14 Self::Read(_) => "read",
15 Self::Sync(_) => "sync",
16 Self::Status(_) => "status",
17 Self::Related(_) => "related",
18 Self::Meta(_) => "meta",
19 Self::Changes(_) => "changes",
20 Self::Inspect(_) => "inspect",
21 Self::Recall(_) => "recall",
22 }
23 }
24}
25
26impl TalonResponseData {
29 #[must_use]
31 pub const fn as_search(&self) -> Option<&SearchResponse> {
32 match self {
33 Self::Search(r) => Some(r),
34 _ => None,
35 }
36 }
37
38 #[must_use]
40 pub const fn as_ask(&self) -> Option<&AskResponse> {
41 match self {
42 Self::Ask(r) => Some(r),
43 _ => None,
44 }
45 }
46
47 #[must_use]
49 pub const fn as_sync(&self) -> Option<&SyncResponse> {
50 match self {
51 Self::Sync(r) => Some(r),
52 _ => None,
53 }
54 }
55
56 #[must_use]
58 pub const fn as_status(&self) -> Option<&StatusResponse> {
59 match self {
60 Self::Status(r) => Some(r),
61 _ => None,
62 }
63 }
64
65 #[must_use]
67 pub const fn as_related(&self) -> Option<&RelatedResponse> {
68 match self {
69 Self::Related(r) => Some(r),
70 _ => None,
71 }
72 }
73
74 #[must_use]
76 pub const fn as_meta(&self) -> Option<&MetaResponse> {
77 match self {
78 Self::Meta(r) => Some(r),
79 _ => None,
80 }
81 }
82
83 #[must_use]
85 pub const fn as_changes(&self) -> Option<&ChangesResponse> {
86 match self {
87 Self::Changes(r) => Some(r),
88 _ => None,
89 }
90 }
91
92 #[must_use]
94 pub const fn as_inspect(&self) -> Option<&InspectResponse> {
95 match self {
96 Self::Inspect(r) => Some(r),
97 _ => None,
98 }
99 }
100
101 #[must_use]
103 pub const fn as_read(&self) -> Option<&ReadResponse> {
104 match self {
105 Self::Read(r) => Some(r),
106 _ => None,
107 }
108 }
109}