pub struct Organization {
pub id: u64,
pub name: String,
pub display_name: String,
pub description: Option<String>,
pub created_by: String,
pub members: Vec<OrgMember>,
pub teams: HashSet<u64>,
pub repos: HashSet<String>,
pub created_at: u64,
pub updated_at: u64,
}Expand description
An organization for multi-user repository ownership.
Fields§
§id: u64Unique organization ID.
name: StringUnique organization name (URL-safe, e.g., “acme-corp”).
display_name: StringDisplay name (e.g., “Acme Corporation”).
description: Option<String>Optional description.
created_by: StringThe creator’s public key (hex).
members: Vec<OrgMember>Organization members.
teams: HashSet<u64>Team IDs belonging to this organization.
repos: HashSet<String>Repository keys owned by this organization.
created_at: u64When the organization was created (Unix timestamp).
updated_at: u64When the organization was last updated (Unix timestamp).
Implementations§
Source§impl Organization
impl Organization
Sourcepub fn new(
id: u64,
name: String,
display_name: String,
created_by: String,
) -> Self
pub fn new( id: u64, name: String, display_name: String, created_by: String, ) -> Self
Create a new organization.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the organization description.
Sourcepub fn get_member(&self, user: &str) -> Option<&OrgMember>
pub fn get_member(&self, user: &str) -> Option<&OrgMember>
Get a member by their public key.
Sourcepub fn has_role(&self, user: &str, required: OrgRole) -> bool
pub fn has_role(&self, user: &str, required: OrgRole) -> bool
Check if a user has at least the specified role.
Sourcepub fn add_member(&mut self, member: OrgMember) -> bool
pub fn add_member(&mut self, member: OrgMember) -> bool
Add a member to the organization.
Sourcepub fn remove_member(&mut self, user: &str) -> Result<bool, &'static str>
pub fn remove_member(&mut self, user: &str) -> Result<bool, &'static str>
Remove a member from the organization. Returns an error string if this would remove the last owner.
Sourcepub fn update_member_role(
&mut self,
user: &str,
new_role: OrgRole,
) -> Result<bool, &'static str>
pub fn update_member_role( &mut self, user: &str, new_role: OrgRole, ) -> Result<bool, &'static str>
Update a member’s role. Returns an error if demoting the last owner.
Sourcepub fn remove_team(&mut self, team_id: u64) -> bool
pub fn remove_team(&mut self, team_id: u64) -> bool
Remove a team from this organization.
Sourcepub fn remove_repo(&mut self, repo_key: &str) -> bool
pub fn remove_repo(&mut self, repo_key: &str) -> bool
Remove a repository from this organization.
Sourcepub fn owner_count(&self) -> usize
pub fn owner_count(&self) -> usize
Count the number of owners.
Trait Implementations§
Source§impl Clone for Organization
impl Clone for Organization
Source§fn clone(&self) -> Organization
fn clone(&self) -> Organization
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more