use snafu::{OptionExt as _, ResultExt as _, Snafu}; use std::str::FromStr; use twilight_model::id::Id; use twilight_model::id::marker::ChannelMarker; pub type VoiceChannel = Id; #[derive(Debug, Snafu)] pub enum TakeError { /// voice channels are supposed to be followed by - Malformed, /// could not parse the voice channel ID ParseIdError { source: ::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)) }