scylla_cql/frame/request/
auth_response.rs1use std::num::TryFromIntError;
4
5use thiserror::Error;
6
7use crate::frame::frame_errors::CqlRequestSerializationError;
8
9use crate::frame::request::{RequestOpcode, SerializableRequest};
10use crate::frame::types::write_bytes_opt;
11
12pub struct AuthResponse {
16    pub response: Option<Vec<u8>>,
18}
19
20impl SerializableRequest for AuthResponse {
21    const OPCODE: RequestOpcode = RequestOpcode::AuthResponse;
22
23    fn serialize(&self, buf: &mut Vec<u8>) -> Result<(), CqlRequestSerializationError> {
24        Ok(write_bytes_opt(self.response.as_ref(), buf)
25            .map_err(AuthResponseSerializationError::ResponseSerialization)?)
26    }
27}
28
29#[non_exhaustive]
31#[derive(Error, Debug, Clone)]
32pub enum AuthResponseSerializationError {
33    #[error("AUTH_RESPONSE body bytes length too big: {0}")]
35    ResponseSerialization(TryFromIntError),
36}