Struct carrier_pigeon::SortedMsgTable
source · [−]pub struct SortedMsgTable { /* private fields */ }
Expand description
A type for collecting the parts needed to send a struct over the network.
This is a variation of MsgTable
. You should use this type only when you don’t know the
order of registration. In place of a constant registration order, types must be registered
with a unique string identifier. The list is then sorted on this identifier when built.
If a type is registered with the same name, it will be ignored, therefore namespacing is encouraged if you are allowing mods or external plugins to add networking types.
IMPORTANT: The Message tables on all clients and the server need to have exactly the same types registered, although they do not need to be registered in the same order.
Implementations
sourceimpl SortedMsgTable
impl SortedMsgTable
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SortedMsgTable
.
sourcepub fn join(&mut self, other: &SortedMsgTable) -> Result<(), MsgRegError>
pub fn join(&mut self, other: &SortedMsgTable) -> Result<(), MsgRegError>
Adds all registrations from other
into this table.
All errors are thrown before mutating self. If no errors are thrown, all entries are added; if an error is thrown, no entries are added.
sourcepub fn is_registered<T>(&self) -> bool where
T: Any + Send + Sync + DeserializeOwned + Serialize,
pub fn is_registered<T>(&self) -> bool where
T: Any + Send + Sync + DeserializeOwned + Serialize,
If type T
has been registered or not.
sourcepub fn tid_registered(&self, tid: TypeId) -> bool
pub fn tid_registered(&self, tid: TypeId) -> bool
If the type with TypeId
tid
has been registered or not.
sourcepub fn identifier_registered(&self, identifier: &str) -> bool
pub fn identifier_registered(&self, identifier: &str) -> bool
If the type with TypeId
tid
has been registered or not.
sourcepub fn register<T>(
&mut self,
transport: Transport,
identifier: &str
) -> Result<(), MsgRegError> where
T: Any + Send + Sync + DeserializeOwned + Serialize,
pub fn register<T>(
&mut self,
transport: Transport,
identifier: &str
) -> Result<(), MsgRegError> where
T: Any + Send + Sync + DeserializeOwned + Serialize,
Registers a message type so that it can be sent over the network.
sourcepub fn build<C, R, D>(self) -> Result<MsgTableParts, MsgRegError> where
C: Any + Send + Sync + DeserializeOwned + Serialize,
R: Any + Send + Sync + DeserializeOwned + Serialize,
D: Any + Send + Sync + DeserializeOwned + Serialize,
pub fn build<C, R, D>(self) -> Result<MsgTableParts, MsgRegError> where
C: Any + Send + Sync + DeserializeOwned + Serialize,
R: Any + Send + Sync + DeserializeOwned + Serialize,
D: Any + Send + Sync + DeserializeOwned + Serialize,
Builds the SortedMsgTable
into useful parts.
Consumes the Message table, and turns it into a MsgTableParts
.
This should be called with the generic parameters:
C
is the connection message type.R
is the response message type.f
is the disconnect message type.
The generic parameters should not be registered before hand.
Trait Implementations
sourceimpl Clone for SortedMsgTable
impl Clone for SortedMsgTable
sourcefn clone(&self) -> SortedMsgTable
fn clone(&self) -> SortedMsgTable
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for SortedMsgTable
impl Send for SortedMsgTable
impl Sync for SortedMsgTable
impl Unpin for SortedMsgTable
impl UnwindSafe for SortedMsgTable
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more