Skip to main content

EntityService

Struct EntityService 

Source
pub struct EntityService { /* private fields */ }
Expand description

Unified entity and member management service

Implementations§

Source§

impl EntityService

Source

pub fn new(crdt_manager: Arc<CrdtManager>) -> Self

Create a new entity service

Source

pub async fn create_entity( &self, name: String, entity_type: EntityType, description: Option<String>, created_by: String, initial_members: Vec<String>, ) -> EntityServiceResult<Entity>

Create a new entity

Source

pub async fn get_entity(&self, entity_id: &str) -> EntityServiceResult<Entity>

Get entity by ID

Source

pub async fn list_entities(&self) -> EntityServiceResult<Vec<Entity>>

List all entities

Source

pub async fn add_member( &self, entity_type: EntityType, entity_id: &str, member_id: &str, role: &str, ) -> EntityServiceResult<()>

Add member to entity

Source

pub async fn remove_member( &self, entity_type: EntityType, entity_id: &str, member_id: &str, deleted_by: &str, ) -> EntityServiceResult<()>

Remove member from entity

Source

pub async fn list_members( &self, entity_type: EntityType, entity_id: &str, ) -> EntityServiceResult<Vec<MemberInfo>>

List members of entity

Source

pub async fn set_parent_organization( &self, entity_id: &str, parent_org_id: &str, ) -> EntityServiceResult<()>

Set parent organization for a child entity

Source

pub async fn remove_organization_member( &self, org_id: &str, member_id: &str, deleted_by: &str, ) -> EntityServiceResult<CascadeRemovalResult>

Remove member from organization and all child entities (channels, groups, projects)

Source

pub async fn create_local_entity( &self, name: String, entity_type: EntityType, description: Option<String>, created_by: String, ) -> EntityServiceResult<Entity>

Create a new local-only entity (no network identity)

Link an existing entity to a network identity

Source

pub async fn mark_entity_synced( &self, entity_id: &str, ) -> EntityServiceResult<Entity>

Update entity sync timestamp

Source

pub async fn update_entity( &self, entity_id: &str, name: Option<String>, description: Option<Option<String>>, ) -> EntityServiceResult<Entity>

Source

pub async fn delete_entity(&self, entity_id: &str) -> EntityServiceResult<()>

Source

pub async fn import_entity( &self, id: String, name: String, entity_type: EntityType, description: Option<String>, created_by: String, created_at: i64, joiner_four_words: String, role: String, ) -> EntityServiceResult<Entity>

Import/join an existing entity by ID (for multi-node sync)

This allows a node to join an entity that was created on another node. The caller provides the entity metadata including the original ID.

Source

pub async fn set_permission_override( &self, entity_type: EntityType, entity_id: &str, member_id: &str, resource_type: &str, access_level: &str, ) -> EntityServiceResult<()>

Set a permission override for a member

Stores the override in the entity’s CRDT document under the member’s permission_overrides map. This override takes precedence over role defaults.

Source

pub async fn remove_permission_override( &self, entity_type: EntityType, entity_id: &str, member_id: &str, resource_type: &str, ) -> EntityServiceResult<()>

Remove a permission override for a member

Removes the override, reverting to the member’s role default for that resource.

Source

pub async fn get_permission_overrides( &self, entity_type: EntityType, entity_id: &str, member_id: &str, ) -> EntityServiceResult<Vec<(String, String)>>

Get all permission overrides for a member

Returns a map of resource_type -> access_level for all overrides.

Source

pub async fn set_member_role( &self, entity_type: EntityType, entity_id: &str, member_id: &str, new_role: &str, ) -> EntityServiceResult<()>

Update a member’s role

Changes the member’s role in the CRDT document. Note that this does not clear existing permission overrides - they continue to take precedence.

Source

pub async fn get_member_role( &self, entity_type: EntityType, entity_id: &str, member_id: &str, ) -> EntityServiceResult<String>

Get a member’s role from the CRDT document

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more