Implement first draft of raw write serverside

This commit is contained in:
Nadja Reitzenstein
2023-01-18 15:58:32 +01:00
parent 946a08c19c
commit b8092e9090
4 changed files with 44 additions and 15 deletions

View File

@ -1,5 +1,4 @@
use std::fmt::{Debug, Display, Formatter};
use std::{fmt, hash::Hasher};
use std::fmt;
use std::ops::Deref;
@ -20,6 +19,16 @@ pub mod value;
#[archive_attr(derive(Debug))]
pub struct State {
pub inner: MachineState,
pub raw: Vec<u8>,
}
impl State {
pub fn new(inner: MachineState) -> Self {
Self::with_raw(inner, Vec::new())
}
pub fn with_raw(inner: MachineState, raw: Vec<u8>) -> Self {
Self { inner, raw }
}
}
impl fmt::Debug for State {
@ -34,8 +43,8 @@ impl fmt::Debug for State {
}
impl fmt::Display for ArchivedState {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Display::fmt(&self.inner, f)
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.inner, f)
}
}
@ -62,7 +71,7 @@ struct StateVisitor;
impl<'de> serde::de::Visitor<'de> for StateVisitor {
type Value = State;
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a map from OIDs to value objects")
}
@ -75,7 +84,7 @@ impl<'de> serde::de::Visitor<'de> for StateVisitor {
));
}
let val: MachineState = map.next_value()?;
Ok(State { inner: val })
Ok(State { inner: val, raw: Vec::new() })
}
}