feat: add user_list, allow config::new with &str

This commit is contained in:
əlemi 2024-09-21 12:05:09 +02:00
parent 9218e9e9c7
commit 2f6557f971
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 12 additions and 3 deletions

View file

@ -27,10 +27,10 @@ pub struct Config {
impl Config {
/// construct a new Config object, with given username and password
pub fn new(username: String, password: String) -> Self {
pub fn new(username: impl ToString, password: impl ToString) -> Self {
Self {
username,
password,
username: username.to_string(),
password: password.to_string(),
host: None,
port: None,
tls: None,

View file

@ -278,6 +278,15 @@ impl Workspace {
.collect()
}
/// Get all names of users currently in this workspace
pub fn user_list(&self) -> Vec<String> {
self.0
.users
.iter()
.map(|elem| elem.value().name.clone())
.collect()
}
/// Get the filetree as it is currently cached.
/// A filter may be applied, and it may be strict (equality check) or not (starts_with check).
// #[cfg_attr(feature = "js", napi)] // https://github.com/napi-rs/napi-rs/issues/1120