pub struct ProtobufDecoder<T> { /* private fields */ }Expand description
Protobuf 消息解码器,支持粘包处理
Implementations§
Source§impl<T> ProtobufDecoder<T>
impl<T> ProtobufDecoder<T>
Sourcepub fn decode_next(&mut self) -> Result<Option<T>, Box<dyn Error + Send + Sync>>
pub fn decode_next(&mut self) -> Result<Option<T>, Box<dyn Error + Send + Sync>>
解码下一个完整的消息
返回 Ok(Some(message)) 如果有足够的数据解码一个完整的消息 返回 Ok(None) 如果数据不足(需要更多数据) 返回 Err 如果解码失败
Sourcepub fn has_remaining(&self) -> bool
pub fn has_remaining(&self) -> bool
检查是否还有未处理的数据
Sourcepub fn remaining_len(&self) -> usize
pub fn remaining_len(&self) -> usize
获取剩余数据长度
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ProtobufDecoder<T>
impl<T> RefUnwindSafe for ProtobufDecoder<T>where
T: RefUnwindSafe,
impl<T> Send for ProtobufDecoder<T>where
T: Send,
impl<T> Sync for ProtobufDecoder<T>where
T: Sync,
impl<T> Unpin for ProtobufDecoder<T>where
T: Unpin,
impl<T> UnsafeUnpin for ProtobufDecoder<T>
impl<T> UnwindSafe for ProtobufDecoder<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more