chore: refactor into a RecordingDataManager, lay the ground work for a RenderManager
This commit is contained in:
26
src/recording_data/voice_channel.rs
Normal file
26
src/recording_data/voice_channel.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use snafu::{OptionExt as _, ResultExt as _, Snafu};
|
||||
use std::num::ParseIntError;
|
||||
use std::str::FromStr;
|
||||
use twilight_model::id::Id;
|
||||
use twilight_model::id::marker::ChannelMarker;
|
||||
|
||||
pub type VoiceChannel = Id<ChannelMarker>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
pub enum TakeError {
|
||||
/// voice channels are supposed to be followed by -
|
||||
Malformed,
|
||||
|
||||
/// could not parse the voice channel ID
|
||||
ParseIdError {
|
||||
source: <VoiceChannel as FromStr>::Err,
|
||||
},
|
||||
}
|
||||
|
||||
pub fn take(path: &str) -> Result<(VoiceChannel, &str), TakeError> {
|
||||
let (voice_channel, rest) = path.split_once('-').context(MalformedSnafu)?;
|
||||
|
||||
let voice_channel = voice_channel.parse().context(ParseIdSnafu)?;
|
||||
|
||||
Ok((voice_channel, rest))
|
||||
}
|
||||
Reference in New Issue
Block a user