Added ability to iterate through users in the database
This commit is contained in:
parent
1e5e4c8731
commit
6c3ae626e9
|
@ -83,6 +83,29 @@ impl UserManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Produce a list of all users in the database
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
/// An panics if there is an error reading from the database or if data recieved from
|
||||||
|
/// the database is corrupt
|
||||||
|
pub fn all_users<UserData>(
|
||||||
|
&self,
|
||||||
|
) -> Vec<RegisteredUser<UserData>>
|
||||||
|
where
|
||||||
|
UserData: Serialize + DeserializeOwned
|
||||||
|
{
|
||||||
|
self.users.iter()
|
||||||
|
.map(|result| {
|
||||||
|
let (username, bytes) = result.expect("Failed to connect to database");
|
||||||
|
let inner: PartialUser<UserData> = bincode::deserialize_from(bytes.as_ref())
|
||||||
|
.expect("Received malformed data from database");
|
||||||
|
let username = String::from_utf8(username.to_vec())
|
||||||
|
.expect("Malformed username in database");
|
||||||
|
RegisteredUser::new(username, None, self.clone(), inner)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Attempt to determine the user who sent a request based on the certificate.
|
/// Attempt to determine the user who sent a request based on the certificate.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
|
Loading…
Reference in a new issue