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