batch_mode_batch_schema/
response_request_id.rs1crate::ix!();
3
4#[derive(Debug,Clone,PartialEq,Eq,Hash,Serialize,Deserialize)]
5pub struct ResponseRequestId(String);
6
7impl ResponseRequestId {
8
9 pub fn new(id: impl Into<String>) -> Self {
10 Self(id.into())
11 }
12
13 pub fn as_str(&self) -> &str {
14 &self.0
15 }
16}
17
18impl Deref for ResponseRequestId {
19
20 type Target = str;
21
22 fn deref(&self) -> &Self::Target {
23 &self.0
24 }
25}
26
27impl PartialEq<str> for ResponseRequestId {
28
29 fn eq(&self, other: &str) -> bool {
30 self.as_str() == other
31 }
32}
33
34impl Display for ResponseRequestId {
35
36 fn fmt(&self, f: &mut Formatter) -> FmtResult {
37 Display::fmt(&self.0, f)
38 }
39}
40
41#[cfg(test)]
42mod response_request_id_tests {
43 use super::*;
44
45 #[test]
46 fn test_response_request_id_creation() {
47 let id = ResponseRequestId::new("req_123");
48 pretty_assert_eq!(id.as_str(), "req_123");
49 }
50
51 #[test]
52 fn test_response_request_id_serialization() {
53 let id = ResponseRequestId::new("req_456");
54 let serialized = serde_json::to_string(&id).unwrap();
55 pretty_assert_eq!(serialized, "\"req_456\"");
56 }
57
58 #[test]
59 fn test_response_request_id_deserialization() {
60 let json_data = "\"req_789\"";
61 let id: ResponseRequestId = serde_json::from_str(json_data).unwrap();
62 pretty_assert_eq!(id.as_str(), "req_789");
63 }
64}