feat(proto): add generic proto reader
This commit is contained in:
parent
67af05ea42
commit
413e0216e3
5 changed files with 87 additions and 0 deletions
22
proto/src/reader/protoreader.rs
Normal file
22
proto/src/reader/protoreader.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use crate::reader::utils::AsyncPeek;
|
||||
use tokio::io::AsyncBufRead;
|
||||
|
||||
pub struct ProtoReader<R>
|
||||
where
|
||||
R: AsyncBufRead + AsyncPeek + Unpin + Send,
|
||||
{
|
||||
pub(super) inner: R,
|
||||
pub(super) msg_len_limit: i32,
|
||||
}
|
||||
|
||||
impl<R> ProtoReader<R>
|
||||
where
|
||||
R: AsyncBufRead + AsyncPeek + Unpin + Send,
|
||||
{
|
||||
pub fn new(reader: R, msg_len_limit: i32) -> ProtoReader<R> {
|
||||
ProtoReader {
|
||||
inner: reader,
|
||||
msg_len_limit,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue