use crate::types::{VoiceGatewayReceivePayload, VoiceCloseCode};
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) enum VoiceGatewayCommunication {
Message(VoiceGatewayMessage),
Error(VoiceCloseCode),
}
impl From<VoiceGatewayMessage> for VoiceGatewayCommunication {
fn from(value: VoiceGatewayMessage) -> Self {
Self::Message(value)
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VoiceGatewayMessage(pub String);
impl VoiceGatewayMessage {
pub fn payload(&self) -> Result<VoiceGatewayReceivePayload, serde_json::Error> {
serde_json::from_str(&self.0)
}
}