pub struct LocalEntityMap { /* private fields */ }Expand description
Bidirectional lookup table between GlobalEntity identifiers and their connection-local HostEntity or RemoteEntity counterparts.
Implementations§
Source§impl LocalEntityMap
impl LocalEntityMap
Sourcepub fn new(host_type: HostType) -> Self
pub fn new(host_type: HostType) -> Self
Creates an empty map for the given host_type side of a connection.
Sourcepub fn host_type(&self) -> HostType
pub fn host_type(&self) -> HostType
Returns whether this map belongs to a server or client side.
Sourcepub fn insert_with_host_entity(
&mut self,
global_entity: GlobalEntity,
host_entity: HostEntity,
)
pub fn insert_with_host_entity( &mut self, global_entity: GlobalEntity, host_entity: HostEntity, )
Registers a host-owned mapping from global_entity to host_entity, panicking on duplicate keys.
Sourcepub fn insert_with_static_host_entity(
&mut self,
global_entity: GlobalEntity,
host_entity: HostEntity,
)
pub fn insert_with_static_host_entity( &mut self, global_entity: GlobalEntity, host_entity: HostEntity, )
Registers a static host-owned mapping from global_entity to host_entity, panicking on duplicate keys.
Sourcepub fn insert_with_remote_entity(
&mut self,
global_entity: GlobalEntity,
remote_entity: RemoteEntity,
)
pub fn insert_with_remote_entity( &mut self, global_entity: GlobalEntity, remote_entity: RemoteEntity, )
Registers a remote-owned mapping from global_entity to remote_entity, panicking on duplicate keys.
Sourcepub fn global_entity_from_remote(
&self,
remote_entity: &RemoteEntity,
) -> Option<&GlobalEntity>
pub fn global_entity_from_remote( &self, remote_entity: &RemoteEntity, ) -> Option<&GlobalEntity>
Returns the GlobalEntity mapped from remote_entity, if one exists.
Sourcepub fn global_entity_from_host(
&self,
host_entity: &HostEntity,
) -> Option<&GlobalEntity>
pub fn global_entity_from_host( &self, host_entity: &HostEntity, ) -> Option<&GlobalEntity>
Returns the GlobalEntity mapped from host_entity, if one exists.
Sourcepub fn remove_by_global_entity(
&mut self,
global_entity: &GlobalEntity,
) -> Option<LocalEntityRecord>
pub fn remove_by_global_entity( &mut self, global_entity: &GlobalEntity, ) -> Option<LocalEntityRecord>
Removes the record for global_entity and cleans up the reverse index, returning the record if it existed.
Sourcepub fn contains_global_entity(&self, global_entity: &GlobalEntity) -> bool
pub fn contains_global_entity(&self, global_entity: &GlobalEntity) -> bool
Returns true if global_entity is currently registered in the map.
Sourcepub fn contains_host_entity(&self, host_entity: &HostEntity) -> bool
pub fn contains_host_entity(&self, host_entity: &HostEntity) -> bool
Returns true if host_entity is currently registered in the map.
Sourcepub fn contains_remote_entity(&self, remote_entity: &RemoteEntity) -> bool
pub fn contains_remote_entity(&self, remote_entity: &RemoteEntity) -> bool
Returns true if remote_entity is currently registered in the map.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&GlobalEntity, &LocalEntityRecord)>
pub fn iter(&self) -> impl Iterator<Item = (&GlobalEntity, &LocalEntityRecord)>
Iterates over all (GlobalEntity, LocalEntityRecord) pairs currently in the map.
Sourcepub fn entity_converter(&self) -> &dyn LocalEntityAndGlobalEntityConverter
pub fn entity_converter(&self) -> &dyn LocalEntityAndGlobalEntityConverter
Returns self as a read-only LocalEntityAndGlobalEntityConverter reference.
Sourcepub fn install_entity_redirect(
&mut self,
old_entity: OwnedLocalEntity,
new_entity: OwnedLocalEntity,
)
pub fn install_entity_redirect( &mut self, old_entity: OwnedLocalEntity, new_entity: OwnedLocalEntity, )
Installs a redirect so that lookups of old_entity transparently return new_entity for a TTL period.
Trait Implementations§
Source§impl LocalEntityAndGlobalEntityConverter for LocalEntityMap
impl LocalEntityAndGlobalEntityConverter for LocalEntityMap
Source§fn global_entity_to_host_entity(
&self,
global_entity: &GlobalEntity,
) -> Result<HostEntity, EntityDoesNotExistError>
fn global_entity_to_host_entity( &self, global_entity: &GlobalEntity, ) -> Result<HostEntity, EntityDoesNotExistError>
HostEntity for global_entity if one is registered, or an error otherwise.Source§fn global_entity_to_remote_entity(
&self,
global_entity: &GlobalEntity,
) -> Result<RemoteEntity, EntityDoesNotExistError>
fn global_entity_to_remote_entity( &self, global_entity: &GlobalEntity, ) -> Result<RemoteEntity, EntityDoesNotExistError>
RemoteEntity for global_entity if one is registered, or an error otherwise.Source§fn global_entity_to_owned_entity(
&self,
global_entity: &GlobalEntity,
) -> Result<OwnedLocalEntity, EntityDoesNotExistError>
fn global_entity_to_owned_entity( &self, global_entity: &GlobalEntity, ) -> Result<OwnedLocalEntity, EntityDoesNotExistError>
OwnedLocalEntity (host or remote) for global_entity, or an error if not found.Source§fn host_entity_to_global_entity(
&self,
host_entity: &HostEntity,
) -> Result<GlobalEntity, EntityDoesNotExistError>
fn host_entity_to_global_entity( &self, host_entity: &HostEntity, ) -> Result<GlobalEntity, EntityDoesNotExistError>
GlobalEntity for a dynamic host_entity, or an error if not found.Source§fn static_host_entity_to_global_entity(
&self,
host_entity: &HostEntity,
) -> Result<GlobalEntity, EntityDoesNotExistError>
fn static_host_entity_to_global_entity( &self, host_entity: &HostEntity, ) -> Result<GlobalEntity, EntityDoesNotExistError>
GlobalEntity for a static host_entity, or an error if not found.Source§fn remote_entity_to_global_entity(
&self,
remote_entity: &RemoteEntity,
) -> Result<GlobalEntity, EntityDoesNotExistError>
fn remote_entity_to_global_entity( &self, remote_entity: &RemoteEntity, ) -> Result<GlobalEntity, EntityDoesNotExistError>
GlobalEntity for remote_entity, or an error if not found.Source§fn apply_entity_redirect(&self, entity: &OwnedLocalEntity) -> OwnedLocalEntity
fn apply_entity_redirect(&self, entity: &OwnedLocalEntity) -> OwnedLocalEntity
entity, or entity unchanged if no redirect is installed.Source§fn owned_entity_to_global_entity(
&self,
owned_entity: &OwnedLocalEntity,
) -> Result<GlobalEntity, EntityDoesNotExistError>
fn owned_entity_to_global_entity( &self, owned_entity: &OwnedLocalEntity, ) -> Result<GlobalEntity, EntityDoesNotExistError>
GlobalEntity for owned_entity, dispatching to the appropriate host or remote lookup.