hassium_network/
system.rs1use crate::{
2 client::Client,
3 resource::{Network, NetworkHost},
4 server::Server,
5};
6use core::ecs::{System, WriteExpect};
7use std::marker::PhantomData;
8
9pub struct NetworkSystem<C>
10where
11 C: Client + 'static,
12{
13 _phantom: PhantomData<C>,
14}
15
16impl<C> Default for NetworkSystem<C>
17where
18 C: Client + 'static,
19{
20 fn default() -> Self {
21 Self {
22 _phantom: Default::default(),
23 }
24 }
25}
26
27impl<'s, C> System<'s> for NetworkSystem<C>
28where
29 C: Client + 'static,
30{
31 type SystemData = WriteExpect<'s, Network<C>>;
32
33 fn run(&mut self, mut network: Self::SystemData) {
34 network.process();
35 }
36}
37
38pub struct NetworkHostSystem<S>
39where
40 S: Server + 'static,
41{
42 _phantom: PhantomData<S>,
43}
44
45impl<S> Default for NetworkHostSystem<S>
46where
47 S: Server + 'static,
48{
49 fn default() -> Self {
50 Self {
51 _phantom: Default::default(),
52 }
53 }
54}
55
56impl<'s, S> System<'s> for NetworkHostSystem<S>
57where
58 S: Server + 'static,
59{
60 type SystemData = WriteExpect<'s, NetworkHost<S>>;
61
62 fn run(&mut self, mut network: Self::SystemData) {
63 network.process();
64 }
65}