naia_shared/
lib.rs

1//! # Naia Shared
2//! Common functionality shared between naia-server & naia-client crates.
3
4#![deny(trivial_numeric_casts, unstable_features, unused_import_braces)]
5
6#[macro_use]
7extern crate cfg_if;
8extern crate core;
9
10cfg_if! {
11    if #[cfg(all(target_arch = "wasm32", feature = "wbindgen", feature = "mquad"))]
12    {
13        // Use both protocols...
14        compile_error!("wasm target for 'naia_shared' crate requires either the 'wbindgen' OR 'mquad' feature to be enabled, you must pick one.");
15    }
16    else if #[cfg(all(target_arch = "wasm32", not(feature = "wbindgen"), not(feature = "mquad")))]
17    {
18        // Use no protocols...
19        compile_error!("wasm target for 'naia_shared' crate requires either the 'wbindgen' or 'mquad' feature to be enabled, you must pick one.");
20    }
21}
22
23pub use naia_derive::{
24    Channel, Message, MessageBevy, MessageHecs, Replicate, ReplicateBevy, ReplicateHecs,
25};
26pub use naia_serde::{
27    BitReader, BitWrite, BitWriter, ConstBitLength, FileBitWriter, OutgoingPacket, OwnedBitReader,
28    Serde, SerdeBevyClient, SerdeBevyServer, SerdeBevyShared, SerdeErr, SerdeHecs,
29    SerdeIntegerConversion, SerdeInternal, SignedInteger, SignedVariableInteger, UnsignedInteger,
30    UnsignedVariableInteger, MTU_SIZE_BITS, MTU_SIZE_BYTES,
31};
32pub use naia_socket_shared::{
33    generate_identity_token, link_condition_logic, IdentityToken, Instant, LinkConditionerConfig,
34    Random, SocketConfig, TimeQueue,
35};
36
37mod backends;
38mod bigmap;
39mod connection;
40mod constants;
41mod game_time;
42pub mod handshake;
43mod key_generator;
44mod messages;
45mod protocol;
46mod sequence_list;
47mod types;
48mod world;
49mod wrapping_number;
50
51cfg_if! {
52    if #[cfg(feature = "transport_udp")]{
53        pub mod transport_udp;
54    }
55}
56pub use backends::{Timer, Timestamp};
57pub use connection::{
58    ack_manager::AckManager,
59    bandwidth_monitor::BandwidthMonitor,
60    base_connection::BaseConnection,
61    compression_config::{CompressionConfig, CompressionMode},
62    connection_config::ConnectionConfig,
63    decoder::Decoder,
64    encoder::Encoder,
65    packet_notifiable::PacketNotifiable,
66    packet_type::PacketType,
67    ping_store::{PingIndex, PingStore},
68    standard_header::StandardHeader,
69};
70pub use messages::{
71    channels::{
72        channel::{Channel, ChannelDirection, ChannelMode, ReliableSettings, TickBufferSettings},
73        channel_kinds::{ChannelKind, ChannelKinds},
74        default_channels,
75        receivers::{
76            channel_receiver::ChannelReceiver, ordered_reliable_receiver::OrderedReliableReceiver,
77            unordered_reliable_receiver::UnorderedReliableReceiver,
78        },
79        senders::{
80            channel_sender::{ChannelSender, MessageChannelSender},
81            reliable_sender::ReliableSender,
82            request_sender::LocalResponseId,
83        },
84        system_channel::SystemChannel,
85    },
86    message::{Message, Message as MessageBevy, Message as MessageHecs, MessageBuilder},
87    message_container::MessageContainer,
88    message_kinds::{MessageKind, MessageKinds},
89    message_manager::MessageManager,
90    named::Named,
91    request::{
92        GlobalRequestId, GlobalResponseId, Request, Response, ResponseReceiveKey, ResponseSendKey,
93    },
94};
95pub use world::{
96    component::{
97        component_kinds::{ComponentKind, ComponentKinds},
98        component_update::{ComponentFieldUpdate, ComponentUpdate},
99        diff_mask::DiffMask,
100        entity_property::EntityProperty,
101        property::Property,
102        property_mutate::{PropertyMutate, PropertyMutator},
103        replica_ref::{
104            ReplicaDynMut, ReplicaDynMutTrait, ReplicaDynMutWrapper, ReplicaDynRef,
105            ReplicaDynRefTrait, ReplicaDynRefWrapper, ReplicaMutTrait, ReplicaMutWrapper,
106            ReplicaRefTrait, ReplicaRefWrapper,
107        },
108        replicate::{
109            Replicate, Replicate as ReplicateHecs, Replicate as ReplicateBevy, ReplicateBuilder,
110            ReplicatedComponent,
111        },
112    },
113    delegation::{
114        auth_channel::EntityAuthAccessor,
115        entity_auth_status::{EntityAuthStatus, HostEntityAuthStatus},
116        host_auth_handler::HostAuthHandler,
117    },
118    entity::{
119        entity_action::EntityAction,
120        entity_action_receiver::EntityActionReceiver,
121        entity_action_type::EntityActionType,
122        entity_auth_event::{EntityEventMessage, EntityEventMessageAction},
123        entity_converters::{
124            EntityAndGlobalEntityConverter, EntityAndLocalEntityConverter, EntityConverter,
125            EntityConverterMut, FakeEntityConverter, GlobalWorldManagerType,
126            LocalEntityAndGlobalEntityConverter, LocalEntityAndGlobalEntityConverterMut,
127        },
128        error::EntityDoesNotExistError,
129        global_entity::GlobalEntity,
130        local_entity::{HostEntity, OwnedLocalEntity, RemoteEntity},
131    },
132    host::{
133        global_diff_handler::GlobalDiffHandler,
134        host_world_manager::{HostWorldEvents, HostWorldManager},
135        mut_channel::{MutChannelType, MutReceiver},
136    },
137    local_world_manager::LocalWorldManager,
138    remote::{
139        entity_action_event::EntityActionEvent,
140        entity_event::{EntityEvent, EntityResponseEvent},
141        remote_world_manager::RemoteWorldManager,
142    },
143    shared_global_world_manager::SharedGlobalWorldManager,
144    world_type::{WorldMutType, WorldRefType},
145};
146
147pub use bigmap::{BigMap, BigMapKey};
148pub use game_time::{GameDuration, GameInstant, GAME_TIME_LIMIT};
149pub use key_generator::KeyGenerator;
150pub use messages::channels::senders::request_sender::{
151    LocalRequestOrResponseId, RequestOrResponse,
152};
153pub use protocol::{Protocol, ProtocolPlugin};
154pub use types::{HostType, MessageIndex, PacketIndex, ShortMessageIndex, Tick};
155pub use wrapping_number::{sequence_greater_than, sequence_less_than, wrapping_diff};