-
Notifications
You must be signed in to change notification settings - Fork 5
/
client.rs
35 lines (27 loc) · 718 Bytes
/
client.rs
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
/*
* Created on Sun Sep 10 2023
*
* Copyright (c) storycraft. Licensed under the MIT Licence.
*/
use core::mem::swap;
use loco_protocol::command::{
client::{LocoSink, LocoStream},
Command, Header, Method,
};
#[test]
pub fn read_write_test() {
let mut sink = LocoSink::new();
let command = Command {
header: Header {
id: 0,
status: 1,
method: Method::new("TEST").unwrap(),
data_type: 2,
},
data: Box::new([1_u8, 2, 3]) as Box<[u8]>,
};
sink.send(command.clone());
let mut stream = LocoStream::new();
swap(&mut stream.read_buffer, &mut sink.write_buffer);
assert_eq!(stream.read(), Some(command));
}