cql3_parser/
list_role.rs

1use crate::common::Identifier;
2use std::fmt::{Display, Formatter};
3
4/// https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/cqlListRoles.html
5#[derive(PartialEq, Debug, Clone)]
6pub struct ListRole {
7    /// List roles only for this role.
8    pub of: Option<Identifier>,
9    /// if true the NORECURSIVE option has been set.
10    pub no_recurse: bool,
11}
12
13impl Display for ListRole {
14    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15        let mut s: String = "".to_string();
16        if let Some(of) = &self.of {
17            s = " OF ".to_string();
18            s.push_str(of.to_string().as_str());
19        }
20        write!(
21            f,
22            "LIST ROLES{}{}",
23            s.as_str(),
24            if self.no_recurse { " NORECURSIVE" } else { "" }
25        )
26    }
27}