pub fn write_cmd<'a, T: serde::Serialize>(
    buf: &'a mut Vec<u8>,
    value: &T,
) -> Result<&'a [u8], Error> {
    // u32::MAX == 4,294,967,295
    const MAX_DIGITS: usize = 10;
    // *999\r\n
    const CMD_HEADER_CAP: usize = 1 + MAX_DIGITS + 2;

    buf.resize(CMD_HEADER_CAP, 0);
    let count = value.serialize(CommandSerializer::new(buf))?;

    let mut hbuf = &mut buf[..CMD_HEADER_CAP];
    Token::Array(Some(count)).put(&mut hbuf);
    let offset = hbuf.len();
    buf.copy_within(..CMD_HEADER_CAP - offset, offset);

    Ok(&buf[offset..])
}
/// Write the command to the buffer.
///
/// *Do not use* the content of the buffer itself; use the returned slice instead.
/// For efficiency, the buffer may contain invalid bytes at the beginning after this operation,
/// and therefore using its content as command may result in failure.
Write the command to the buffer.
Do not use* the content of the buffer itself; use the returned slice instead.
For efficiency, the buffer may contain invalid bytes at the beginning after this operation,
and therefore using its content as command may result in failure.
Write the command to the buffer . Do not use * the content of the buffer itself ; use the returned slice instead . For efficiency the buffer may contain invalid bytes at the beginning after this operation and therefore using its content as command may result in failure .
pub fn write_cmd<'a, T: serde::Serialize>(
    buf: &'a mut Vec<u8>,
    value: &T,
) -> Result<&'a [u8], Error> {
    // u32::MAX == 4,294,967,295
    const MAX_DIGITS: usize = 10;
    // *999\r\n
    const CMD_HEADER_CAP: usize = 1 + MAX_DIGITS + 2;
    buf.resize(CMD_HEADER_CAP, 0);
    let count = value.serialize(CommandSerializer::new(buf))?;
    let mut hbuf = &mut buf[..CMD_HEADER_CAP];
    Token::Array(Some(count)).put(&mut hbuf);
    let offset = hbuf.len();
    buf.copy_within(..CMD_HEADER_CAP - offset, offset);
    Ok(&buf[offset..])
}
pub fn write_cmd < ' a , T : serde :: Serialize > ( buf : & ' a mut Vec < u8 > , value : & T , ) -> Result < & ' a [ u8 ] , Error > { // u32::MAX == 4,294,967,295 const MAX_DIGITS : usize = 10 ; // *999\r\n const CMD_HEADER_CAP : usize = 1 + MAX_DIGITS + 2 ; buf . resize ( CMD_HEADER_CAP , 0 ) ; let count = value . serialize ( CommandSerializer :: new ( buf ) ) ? ; let mut hbuf = & mut buf [ .. CMD_HEADER_CAP ] ; Token :: Array ( Some ( count ) ) . put ( & mut hbuf ) ; let offset = hbuf . len ( ) ; buf . copy_within ( .. CMD_HEADER_CAP - offset , offset ) ; Ok ( & buf [ offset .. ] ) }
Write the command to the buffer.
Write the command to the buffer .
buf
&'a mut Vec<u8>
value
&T