1use crate::{ChainId, MescError, TryIntoChainId};
2
3#[derive(Debug, Default, Clone)]
5pub struct MultiEndpointQuery {
6 pub chain_id: Option<ChainId>,
8 pub name_contains: Option<String>,
10 pub url_contains: Option<String>,
12}
13
14impl MultiEndpointQuery {
16 pub fn new() -> Self {
18 Self::default()
19 }
20
21 pub fn chain_id<T: TryIntoChainId>(mut self, chain_id: T) -> Result<Self, MescError> {
23 self.chain_id = Some(chain_id.try_into_chain_id()?);
24 Ok(self)
25 }
26
27 pub fn name<T: AsRef<str>>(mut self, query: T) -> Result<Self, MescError> {
29 self.name_contains = Some(query.as_ref().to_string());
30 Ok(self)
31 }
32
33 pub fn url<T: AsRef<str>>(mut self, query: T) -> Result<Self, MescError> {
35 self.url_contains = Some(query.as_ref().to_string());
36 Ok(self)
37 }
38}
39
40#[derive(Debug, Clone)]
46pub struct EndpointQuery {
47 pub query_type: EndpointQueryType,
49 pub fields: EndpointQueryFields,
51}
52
53#[derive(Debug, Clone)]
55pub enum EndpointQueryType {
56 DefaultEndpoint,
58 EndpointByName,
60 EndpointByNetwork,
62 UserInput,
64}
65
66#[derive(Debug, Clone)]
68pub enum EndpointQueryFields {
69 DefaultEndpoint(DefaultEndpointQuery),
71 EndpointName(EndpointNameQuery),
73 EndpointNetwork(EndpointNetworkQuery),
75 UserInput(UserInputQuery),
77}
78
79#[derive(Debug, Clone)]
81pub struct DefaultEndpointQuery {
82 pub profile: Option<String>,
84}
85
86#[derive(Debug, Clone)]
88pub struct EndpointNameQuery {
89 pub name: String,
91}
92
93#[derive(Debug, Clone)]
95pub struct EndpointNetworkQuery {
96 pub profile: Option<String>,
98 pub chain_id: String,
100}
101
102#[derive(Debug, Clone)]
104pub struct UserInputQuery {
105 pub profile: Option<String>,
107 pub user_input: String,
109}
110
111#[derive(Debug, Clone)]
117pub struct GlobalMetadataQuery {
118 pub profile: Option<String>,
120 pub path: Option<Vec<String>>,
122}
123
124#[derive(Debug, Clone)]
130pub struct MescQuery {
131 pub query_type: MescQueryType,
133 pub fields: MescQueryFields,
135}
136
137#[derive(Debug, Clone)]
139pub enum MescQueryType {
140 DefaultEndpoint,
142 EndpointByName,
144 EndpointByNetwork,
146 UserInput,
148 MultiEndpoint,
150 GlobalMetadata,
152}
153
154#[derive(Debug, Clone)]
156pub enum MescQueryFields {
157 DefaultEndpoint(DefaultEndpointQuery),
159 EndpointName(EndpointNameQuery),
161 EndpointNetwork(EndpointNetworkQuery),
163 UserInput(UserInputQuery),
165 MultiEndpoint(MultiEndpointQuery),
167 GlobalMetadata(GlobalMetadataQuery),
169}