use rs_teststand_sys::Dispatch;
use crate::Error;
use crate::dispids::users_file;
use crate::property::{PropertyObject, PropertyObjectFile};
#[derive(Debug)]
pub struct UsersFile {
dispatch: Box<dyn Dispatch>,
}
impl UsersFile {
pub(crate) fn new(dispatch: Box<dyn Dispatch>) -> Self {
Self { dispatch }
}
pub fn user_list(&self) -> Result<PropertyObject, Error> {
Ok(PropertyObject::new(
self.dispatch.get(users_file::USER_LIST)?.into_object()?,
))
}
pub fn user_group_list(&self) -> Result<PropertyObject, Error> {
Ok(PropertyObject::new(
self.dispatch
.get(users_file::USER_GROUP_LIST)?
.into_object()?,
))
}
pub fn user_profile_list(&self) -> Result<PropertyObject, Error> {
Ok(PropertyObject::new(
self.dispatch
.get(users_file::USER_PROFILE_LIST)?
.into_object()?,
))
}
pub fn reload_from_disk(&self) -> Result<(), Error> {
self.dispatch.call(users_file::RELOAD_FROM_DISK, &[])?;
Ok(())
}
pub fn as_property_object_file(&self) -> Result<PropertyObjectFile, Error> {
Ok(PropertyObjectFile::new(
self.dispatch
.call(users_file::AS_PROPERTY_OBJECT_FILE, &[])?
.into_object()?,
))
}
}