Model workspaces, users, and organizations
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
use super::{
|
||||
id::{IdError, validate_id},
|
||||
organization::OrganizationId,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
pub struct WorkspaceId(String);
|
||||
|
||||
impl WorkspaceId {
|
||||
pub const MAX_BYTES: usize = 96;
|
||||
|
||||
pub fn new(value: impl Into<String>) -> Result<Self, IdError> {
|
||||
let value = value.into();
|
||||
validate_id(&value, Self::MAX_BYTES, IdError::Workspace)?;
|
||||
Ok(Self(value))
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// A workspace belongs to one organization and contains documents.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Workspace {
|
||||
pub id: WorkspaceId,
|
||||
pub organization_id: OrganizationId,
|
||||
pub name: String,
|
||||
}
|
||||
Reference in New Issue
Block a user