chore: refactor into a RecordingDataManager, lay the ground work for a RenderManager
This commit is contained in:
21
src/recording_data/microsecond.rs
Normal file
21
src/recording_data/microsecond.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use snafu::{OptionExt as _, ResultExt as _, Snafu};
|
||||
use std::num::ParseIntError;
|
||||
|
||||
pub type Microsecond = u32;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
pub enum TakeError {
|
||||
/// microseconds are supposed to be followed by -
|
||||
Malformed,
|
||||
|
||||
/// could not parse the microsecond as an integer
|
||||
ParseIntegerError { source: ParseIntError },
|
||||
}
|
||||
|
||||
pub fn take(path: &str) -> Result<(Microsecond, &str), TakeError> {
|
||||
let (microsecond, rest) = path.split_once('-').context(MalformedSnafu)?;
|
||||
|
||||
let microsecond = microsecond.parse().context(ParseIntegerSnafu)?;
|
||||
|
||||
Ok((microsecond, rest))
|
||||
}
|
||||
Reference in New Issue
Block a user