cassandra_proto/frame/
frame_authenticate.rs1use std::io::Cursor;
2
3use crate::frame::FromCursor;
4use crate::error;
5use crate::types::CString;
6
7#[derive(Debug)]
9pub struct BodyResAuthenticate {
10 pub data: CString,
11}
12
13impl FromCursor for BodyResAuthenticate {
14 fn from_cursor(mut cursor: &mut Cursor<&[u8]>) -> error::Result<BodyResAuthenticate> {
15 Ok(BodyResAuthenticate { data: CString::from_cursor(&mut cursor)?, })
16 }
17}
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22 use std::io::Cursor;
23 use crate::frame::traits::FromCursor;
24
25 #[test]
26 fn body_res_authenticate() {
27 let data = [0, 5, 97, 98, 99, 100, 101];
29 let mut cursor: Cursor<&[u8]> = Cursor::new(&data);
30 let body = BodyResAuthenticate::from_cursor(&mut cursor).unwrap();
31 assert_eq!(body.data.as_str(), "abcde");
32 }
33}