chore(trace-handler): sub/-trace len dedicated alias to replace usize [fixes VM-282] (#569)

feat(trace-handler): sub/-trace len dedicated alias to replace usize [fixes VM-282]
This commit is contained in:
raftedproc
2023-05-02 16:32:18 +03:00
committed by GitHub
parent 80486ed6ad
commit b480e018b4
11 changed files with 150 additions and 52 deletions

View File

@ -16,12 +16,16 @@
use super::ExecutedState;
use crate::TracePos;
use serde::Deserialize;
use serde::Serialize;
use std::convert::TryInto;
use std::ops::Deref;
use std::ops::Index;
use std::ops::IndexMut;
pub type TraceLen = u32;
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ExecutionTrace(Vec<ExecutedState>);
@ -42,6 +46,13 @@ impl ExecutionTrace {
pub fn push(&mut self, value: ExecutedState) {
self.0.push(value);
}
pub fn trace_states_count(&self) -> TraceLen {
self.0
.len()
.try_into()
.expect("there is an overflow in trace_states_count().")
}
}
impl Deref for ExecutionTrace {