cassandra_proto/frame/
frame_auth_challenge.rs1use std::io::Cursor;
2
3use crate::frame::FromCursor;
4use crate::error;
5use crate::types::CBytes;
6
7#[derive(Debug)]
9pub struct BodyResAuthChallenge {
10 pub data: CBytes,
11}
12
13impl FromCursor for BodyResAuthChallenge {
14 fn from_cursor(mut cursor: &mut Cursor<&[u8]>) -> error::Result<BodyResAuthChallenge> {
15 CBytes::from_cursor(&mut cursor).map(|data| BodyResAuthChallenge { data: data })
16 }
17}
18
19#[cfg(test)]
20mod tests {
21 use std::io::Cursor;
22 use super::*;
23 use crate::frame::traits::FromCursor;
24
25 #[test]
26 fn body_res_auth_challenge_from_cursor() {
27 let few_bytes = &[0, 0, 0, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
28 let mut cursor: Cursor<&[u8]> = Cursor::new(few_bytes);
29 let body = BodyResAuthChallenge::from_cursor(&mut cursor).unwrap();
30 assert_eq!(body.data.into_plain().unwrap(),
31 vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
32 }
33}