kixelated c5d8873e4e
Webtransport generic (#51)
Switched to the webtransport-generic crate so quinn or quiche (with
adapter) can be used. This also involved switching out the
decoder/encoder since it meant a wrapper was required.
2023-08-15 10:20:03 -07:00

20 lines
467 B
Rust

use crate::{coding::DecodeError, message::Message};
use webtransport_generic::RecvStream;
pub struct Receiver<R: RecvStream> {
stream: R,
}
impl<R: RecvStream> Receiver<R> {
pub fn new(stream: R) -> Self {
Self { stream }
}
// Read the next full message from the stream.
// NOTE: This is not cancellable; you must poll the future to completion.
pub async fn recv(&mut self) -> Result<Message, DecodeError> {
Message::decode(&mut self.stream).await
}
}