rcfe_core/client.rs
1use crate::{kv::KVClient, options::client::ClientOptions};
2
3/// Client trait defining the interface for a client.
4/// Implementors must provide methods to retrieve client options and a key-value client.
5///
6/// # Examples
7/// ```rust
8/// use rcfe_core::Client;
9/// use rcfe_core::options::client::ClientOptions;
10/// use rcfe_core::kv::KVClient;
11///
12/// struct MyClient;
13///
14/// impl Client for MyClient {
15/// fn get_options(&self) -> &ClientOptions {
16/// unimplemented!()
17/// }
18/// fn get_kv_client(&self) -> impl KVClient {
19/// unimplemented!()
20/// }
21/// }
22/// let my_client = MyClient;
23/// let options = my_client.get_options();
24/// let kv_client = my_client.get_kv_client();
25/// ```
26pub trait Client {
27 /// Get a reference to the client options.
28 /// # Returns
29 /// A reference to the `ClientOptions`.
30 /// # Examples
31 /// ```rust
32 /// use rcfe_core::Client;
33 /// use rcfe_core::options::client::ClientOptions;
34 ///
35 /// struct MyClient;
36 ///
37 /// impl Client for MyClient {
38 /// fn get_options(&self) -> &ClientOptions {
39 /// unimplemented!()
40 /// }
41 /// fn get_kv_client(&self) -> impl KVClient {
42 /// unimplemented!()
43 /// }
44 /// }
45 /// let my_client = MyClient;
46 /// let options = my_client.get_options();
47 /// ```
48 fn get_options(&self) -> &ClientOptions;
49
50 /// Get the key-value client.
51 /// # Returns
52 /// An implementation of the `KVClient` trait.
53 /// # Examples
54 /// ```rust
55 /// use rcfe_core::Client;
56 /// use rcfe_core::options::client::ClientOptions;
57 /// use rcfe_core::kv::KVClient;
58 ///
59 /// struct MyClient;
60 ///
61 /// impl Client for MyClient {
62 /// fn get_options(&self) -> &ClientOptions {
63 /// unimplemented!()
64 /// }
65 /// fn get_kv_client(&self) -> impl KVClient {
66 /// unimplemented!()
67 /// }
68 /// }
69 /// let my_client = MyClient;
70 /// let kv_client = my_client.get_kv_client();
71 /// ```
72 fn get_kv_client(&self) -> impl KVClient;
73}