1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Rustdis is a partial Redis server implementation intended purely for educational purposes.
//!
//! The primary goal of rustdis is to offer a straightforward and comprehensible implementation,
//! with no optimization techniques to ensure the code remains accessible and easy to understand.
//! As of now, rustdis focuses exclusively on implementing Redis' String data type and its
//! associated methods. You can find more about Redis strings here:
//! [Redis Strings](https://redis.io/docs/data-types/strings/).
//!
//! # Architecture
//!
//! * `server`: Redis server module. Provides a run function that initiates the server, enabling it
//! to begin handling incoming connections from Redis clients. It manages client requests, executes
//! Redis commands, and handles connection lifecycles.
//!
//! * `connection`: The Connection module manages a TCP connection for a Redis client. It separates
//! the TCP stream into readable and writable components to facilitate data consumption and
//! transmission. The server uses this connection module to read data from the TCP connection.
//!
//! * `codec`: This module is responsible for decoding raw TCP byte streams into `Frame` data
//! structures. This is an essential component for translating incoming client requests into
//! meaningful Redis commands.
//!
//! * `frame`: This module defines the `Frame` enum, representing different types of Redis protocol
//! messages, and provides parsing and serialization functionalities. It adheres to the RESP (Redis
//! Serialization Protocol) specifications.
//!
//! * `store`: This module provides a simple key-value store for managing Redis string data types.
//! It supports basic operations such as setting, getting, removing, and incrementing values
//! associated with keys.
//!
//! ```text
//!
//! +--------------------------------------+
//! | Redis Client |
//! +-------------------+------------------+
//! |
//! | Request (e.g., SET key value)
//! v
//! +-------------------+------------------+
//! | Server |
//! | (module: server, function: run) |
//! +-------------------+------------------+
//! |
//! | Accept Connection
//! v
//! +-------------------+------------------+
//! | Connection |
//! | (module: connection, manages TCP |
//! | connections and streams) |
//! +-------------------+------------------+
//! |
//! | Read Data from TCP Stream
//! v
//! +-------------------+------------------+
//! | Codec |
//! | (module: codec, function: decode) |
//! +-------------------+------------------+
//! |
//! | Decode Request
//! v
//! +-------------------+------------------+
//! | Frame |
//! | (module: frame, function: parse) |
//! +-------------------+------------------+
//! |
//! | Parse Command and Data
//! v
//! +-------------------+------------------+
//! | Store |
//! | (module: store, manages key-value |
//! | data storage) |
//! +-------------------+------------------+
//! |
//! | Execute Command (e.g., set, get, incr_by)
//! v
//! +-------------------+------------------+
//! | Frame |
//! | (module: frame, function: serialize)|
//! +-------------------+------------------+
//! |
//! | Encode Response
//! v
//! +-------------------+------------------+
//! | Codec |
//! | (module: codec, function: encode) |
//! +-------------------+------------------+
//! |
//! | Write Data to TCP Stream
//! v
//! +-------------------+------------------+
//! | Connection |
//! | (module: connection, manages TCP |
//! | connections and streams) |
//! +-------------------+------------------+
//! |
//! | Send Response
//! v
//! +-------------------+------------------+
//! | Redis Client |
//! +--------------------------------------+
//!
//! ```
pub type Error = ;
pub type Result<T> = Result;