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
//! Bidirectional Memcache protocol implementation.
//!
//! This crate provides complete Memcache protocol support for both client
//! and server implementations. Both ASCII and binary protocols are supported.
//!
//! # Features
//!
//! - `ascii` (default): ASCII text protocol support
//! - `binary`: Binary protocol support
//! - `full`: Both ASCII and binary protocols
//!
//! # ASCII Protocol
//!
//! The ASCII protocol is text-based and human-readable. It's easier to debug
//! but has more parsing overhead.
//!
//! ## Example - Client Side
//!
//! ```
//! use memcache_proto::{Request, Response};
//!
//! // Encode a GET command
//! let mut buf = vec![0u8; 1024];
//! let len = Request::get(b"mykey").encode(&mut buf);
//!
//! // Parse the response
//! let response_data = b"VALUE mykey 0 5\r\nhello\r\nEND\r\n";
//! let (response, consumed) = Response::parse(response_data).unwrap();
//! ```
//!
//! ## Example - Server Side
//!
//! ```
//! use memcache_proto::{Command, Response};
//!
//! // Parse an incoming command
//! let request_data = b"get mykey\r\n";
//! let (cmd, consumed) = Command::parse(request_data).unwrap();
//!
//! // Encode a response
//! let mut buf = vec![0u8; 1024];
//! let len = Response::stored().encode(&mut buf);
//! ```
//!
//! # Binary Protocol
//!
//! The binary protocol uses fixed 24-byte headers and is more efficient for
//! high-throughput scenarios. Enable with the `binary` feature.
//!
//! ```ignore
//! use memcache_proto::binary::{BinaryRequest, BinaryResponse, Opcode};
//!
//! // Encode a GET request
//! let mut buf = [0u8; 256];
//! let len = BinaryRequest::encode_get(&mut buf, b"mykey", 1);
//! ```
pub use ;
pub use ParseError;
pub use ;
pub use ;
pub use ;