use serde::Serialize;
#[derive(Serialize, Debug)]
pub struct Permissions<'a> {
pub user: &'a str,
pub vhost: &'a str,
pub configure: &'a str,
pub read: &'a str,
pub write: &'a str,
}
impl<'a> Permissions<'a> {
pub fn full_access(user: &'a str, vhost: &'a str) -> Self {
Self {
user,
vhost,
configure: ".*",
read: ".*",
write: ".*",
}
}
pub fn read_only(user: &'a str, vhost: &'a str) -> Self {
Self {
user,
vhost,
configure: "",
read: ".*",
write: "",
}
}
pub fn no_access(user: &'a str, vhost: &'a str) -> Self {
Self {
user,
vhost,
configure: "",
read: "",
write: "",
}
}
}
#[derive(Serialize, Debug)]
pub struct TopicPermissions<'a> {
pub user: &'a str,
pub vhost: &'a str,
pub write: &'a str,
pub read: &'a str,
pub exchange: &'a str,
}