pub struct RemotingCommandCodec(/* private fields */);Expand description
Encodes a RemotingCommand into a BytesMut buffer.
This method takes a RemotingCommand and a mutable reference to a BytesMut buffer as
parameters. It first encodes the header of the RemotingCommand and calculates the lengths of
the header and body. It then reserves the necessary space in the BytesMut buffer and writes
the total length, serialize type, header, and body to the buffer.
§Arguments
item- ARemotingCommandthat is to be encoded.dst- A mutable reference to aBytesMutbuffer where the encoded command will be written.
§Returns
Result<(), Self::Error>- ReturnsOk(())if the encoding is successful, otherwise returns anErrwith aRemotingError.
§Errors
This function will return an error if the encoding process fails.
Implementations§
Trait Implementations§
Source§impl Clone for RemotingCommandCodec
impl Clone for RemotingCommandCodec
Source§fn clone(&self) -> RemotingCommandCodec
fn clone(&self) -> RemotingCommandCodec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RemotingCommandCodec
impl Debug for RemotingCommandCodec
Source§impl Decoder for RemotingCommandCodec
impl Decoder for RemotingCommandCodec
Source§fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error>
fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>
Decodes a RemotingCommand from a BytesMut buffer.
This method takes a mutable reference to a BytesMut buffer as a parameter.
It first checks if there are at least 4 bytes in the buffer, if not, it returns Ok(None).
Then it reads the total size of the incoming data as a big-endian i32 from the first 4
bytes. If the available data is less than the total size, it returns Ok(None).
It then splits the BytesMut buffer to get the command data including the total size and
discards the first i32 (total size). It reads the header length as a big-endian i32 and
checks if the header length is greater than the total size minus 4. If it is, it returns
an error. It then splits the buffer again to get the header data and deserializes it
into a RemotingCommand. If the total size minus 4 is greater than the header length,
it sets the body of the RemotingCommand.
§Arguments
src- A mutable reference to aBytesMutbuffer from which theRemotingCommandwill be decoded.
§Returns
Result<Option<Self::Item>, Self::Error>- ReturnsOk(Some(cmd))if the decoding is successful, otherwise returns anErrwith aRemotingError.
§Errors
This function will return an error if the decoding process fails.
Source§type Error = RocketmqError
type Error = RocketmqError
Source§type Item = RemotingCommand
type Item = RemotingCommand
Source§impl Default for RemotingCommandCodec
impl Default for RemotingCommandCodec
Source§impl Encoder<RemotingCommand> for RemotingCommandCodec
impl Encoder<RemotingCommand> for RemotingCommandCodec
Source§fn encode(
&mut self,
item: RemotingCommand,
dst: &mut BytesMut,
) -> Result<(), Self::Error>
fn encode( &mut self, item: RemotingCommand, dst: &mut BytesMut, ) -> Result<(), Self::Error>
Encodes a RemotingCommand into a BytesMut buffer.
This method takes a RemotingCommand and a mutable reference to a BytesMut buffer as
parameters. It first encodes the header of the RemotingCommand and calculates the
lengths of the header and body. It then reserves the necessary space in the BytesMut
buffer and writes the total length, serialize type, header, and body to the buffer.
§Arguments
item- ARemotingCommandthat is to be encoded.dst- A mutable reference to aBytesMutbuffer where the encoded command will be written.
§Returns
Result<(), Self::Error>- ReturnsOk(())if the encoding is successful, otherwise returns anErrwith aRemotingError.
§Errors
This function will return an error if the encoding process fails.
Source§type Error = RocketmqError
type Error = RocketmqError
Source§impl Hash for RemotingCommandCodec
impl Hash for RemotingCommandCodec
Source§impl Ord for RemotingCommandCodec
impl Ord for RemotingCommandCodec
Source§fn cmp(&self, other: &RemotingCommandCodec) -> Ordering
fn cmp(&self, other: &RemotingCommandCodec) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RemotingCommandCodec
impl PartialEq for RemotingCommandCodec
Source§impl PartialOrd for RemotingCommandCodec
impl PartialOrd for RemotingCommandCodec
impl Copy for RemotingCommandCodec
impl Eq for RemotingCommandCodec
impl StructuralPartialEq for RemotingCommandCodec
Auto Trait Implementations§
impl Freeze for RemotingCommandCodec
impl RefUnwindSafe for RemotingCommandCodec
impl Send for RemotingCommandCodec
impl Sync for RemotingCommandCodec
impl Unpin for RemotingCommandCodec
impl UnwindSafe for RemotingCommandCodec
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.