intrepid_core/extract/message.rs
use crate::{Context, Frame, MessageFrame};
use super::{Extractor, MessageFrameError, WrongFrameError};
#[derive(Clone, Debug)]
/// Retrieve a [`MessageFrame`] from a [`Frame`], but only if the frame is a message.
pub struct Message(pub MessageFrame);
impl<State> Extractor<State> for Message {
type Error = MessageFrameError;
fn extract(frame: Frame, _: &Context<State>) -> Result<Self, Self::Error> {
match frame {
Frame::Message(message) => Ok(Self(message)),
_ => Err(WrongFrameError.into()),
}
}
}