Limit Snapshot to Conn

This commit is contained in:
Joscha 2023-01-22 19:15:56 +01:00
parent 5a8ad6b40f
commit 1ea5ede442

View file

@ -130,18 +130,16 @@ impl InstanceConfig {
} }
} }
// TODO Make Snapshot a Conn snapshot, not an Instance snapshot /// Snapshot of a [`Conn`]'s state immediately after receiving a packet.
/// Snapshot of an instance at a specific point in time, usually after just #[derive(Debug, Clone)]
/// receiving a packet.
#[derive(Debug)]
pub struct Snapshot { pub struct Snapshot {
pub config: InstanceConfig,
pub conn_tx: ConnTx, pub conn_tx: ConnTx,
pub state: State, pub state: State,
} }
#[derive(Debug)] #[derive(Debug)]
pub struct Event { pub struct Event {
pub config: InstanceConfig,
pub packet: ParsedPacket, pub packet: ParsedPacket,
pub snapshot: Snapshot, pub snapshot: Snapshot,
} }
@ -284,13 +282,14 @@ impl Instance {
{ {
loop { loop {
let packet = conn.recv().await?; let packet = conn.recv().await?;
let event = Event { let snapshot = Snapshot {
packet,
snapshot: Snapshot {
config: config.clone(),
conn_tx: conn.tx().clone(), conn_tx: conn.tx().clone(),
state: conn.state().clone(), state: conn.state().clone(),
}, };
let event = Event {
config: config.clone(),
packet,
snapshot,
}; };
match &event.packet.content { match &event.packet.content {