1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-23 13:59:21 +00:00
comunicapiv3/src/api_data/res_find_virtual_directory.rs

29 lines
738 B
Rust

//! Find virtual directory result
//!
//! @author Pierre Hubert
use serde::{Serialize};
use crate::data::error::ResultBoxError;
use crate::data::user::User;
#[derive(Serialize)]
pub struct ResultFindVirtualDirectory {
kind: String,
id: u64,
}
impl ResultFindVirtualDirectory {
/// Construct a new instance
pub fn new(user: ResultBoxError<User>, group: ResultBoxError<u64>) -> ResultFindVirtualDirectory {
match (user, group) {
// User
(Ok(u), _) => ResultFindVirtualDirectory { kind: "user".to_string(), id: u.id as u64 },
// Group
(_, Ok(g)) => ResultFindVirtualDirectory { kind: "group".to_string(), id: g },
_ => unreachable!()
}
}
}