Organization

Struct Organization 

Source
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: u64

Unique organization ID.

§name: String

Unique organization name (URL-safe, e.g., “acme-corp”).

§display_name: String

Display name (e.g., “Acme Corporation”).

§description: Option<String>

Optional description.

§created_by: String

The 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: u64

When the organization was created (Unix timestamp).

§updated_at: u64

When the organization was last updated (Unix timestamp).

Implementations§

Source§

impl Organization

Source

pub fn new( id: u64, name: String, display_name: String, created_by: String, ) -> Self

Create a new organization.

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Set the organization description.

Source

pub fn get_member(&self, user: &str) -> Option<&OrgMember>

Get a member by their public key.

Source

pub fn is_member(&self, user: &str) -> bool

Check if a user is a member.

Source

pub fn has_role(&self, user: &str, required: OrgRole) -> bool

Check if a user has at least the specified role.

Source

pub fn is_owner(&self, user: &str) -> bool

Check if a user is an owner.

Source

pub fn is_admin(&self, user: &str) -> bool

Check if a user is an admin (or owner).

Source

pub fn add_member(&mut self, member: OrgMember) -> bool

Add a member to the organization.

Source

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.

Source

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.

Source

pub fn add_team(&mut self, team_id: u64)

Add a team to this organization.

Source

pub fn remove_team(&mut self, team_id: u64) -> bool

Remove a team from this organization.

Source

pub fn add_repo(&mut self, repo_key: String)

Add a repository to this organization.

Source

pub fn remove_repo(&mut self, repo_key: &str) -> bool

Remove a repository from this organization.

Source

pub fn owner_count(&self) -> usize

Count the number of owners.

Trait Implementations§

Source§

impl Clone for Organization

Source§

fn clone(&self) -> Organization

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Organization

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Organization

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Organization

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,