tacacs_plus_protocol/authentication/
owned.rs

1use std::borrow::ToOwned;
2use std::string::String;
3use std::string::ToString;
4use std::vec::Vec;
5
6use super::Reply;
7use super::{ReplyFlags, Status};
8use crate::owned::FromBorrowedBody;
9use crate::sealed::Sealed;
10
11/// An authentication reply packet with owned fields.
12#[derive(Debug, Clone, PartialEq, Eq, Hash)]
13pub struct ReplyOwned {
14    /// The status, as returned by the server.
15    pub status: Status,
16
17    /// The flags set in the server response.
18    pub flags: ReplyFlags,
19
20    /// The message to be displayed to the user.
21    pub server_message: String,
22
23    /// The domain-specific data included in the reply.
24    pub data: Vec<u8>,
25}
26
27impl Sealed for ReplyOwned {}
28
29impl FromBorrowedBody for ReplyOwned {
30    type Borrowed<'b> = Reply<'b>;
31
32    fn from_borrowed(borrowed: &Self::Borrowed<'_>) -> Self {
33        ReplyOwned {
34            status: borrowed.status,
35            flags: borrowed.flags,
36            server_message: borrowed.server_message.to_string(),
37            data: borrowed.data.to_owned(),
38        }
39    }
40}