2020-06-03 13:28:28 +02:00
|
|
|
//! Find virtual directory result
|
|
|
|
//!
|
|
|
|
//! @author Pierre Hubert
|
|
|
|
|
|
|
|
use serde::{Serialize};
|
|
|
|
use crate::data::error::ResultBoxError;
|
|
|
|
use crate::data::user::User;
|
2020-06-23 19:01:07 +02:00
|
|
|
use crate::data::group_id::GroupID;
|
2020-06-03 13:28:28 +02:00
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct ResultFindVirtualDirectory {
|
|
|
|
kind: String,
|
|
|
|
id: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ResultFindVirtualDirectory {
|
|
|
|
/// Construct a new instance
|
2020-06-23 19:01:07 +02:00
|
|
|
pub fn new(user: ResultBoxError<User>, group: ResultBoxError<GroupID>) -> ResultFindVirtualDirectory {
|
2020-06-03 13:28:28 +02:00
|
|
|
match (user, group) {
|
|
|
|
|
|
|
|
// User
|
2020-06-25 10:08:34 +02:00
|
|
|
(Ok(u), _) => ResultFindVirtualDirectory { kind: "user".to_string(), id: u.id.id() },
|
2020-06-03 13:28:28 +02:00
|
|
|
|
|
|
|
// Group
|
2020-06-23 19:01:07 +02:00
|
|
|
(_, Ok(g)) => ResultFindVirtualDirectory { kind: "group".to_string(), id: g.id() },
|
2020-06-03 13:28:28 +02:00
|
|
|
|
|
|
|
_ => unreachable!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|