pub async fn write_to<T: AsyncWrite + Unpin + Send>(
        &self,
        mut header: Header,
        stream: &mut T,
    ) -> Result<()> {
        let mut reply_writer = Vec::new();
        reply_writer.write_u32(self.flags.bits()).await?;
        reply_writer
            .write_all(&self.cursor_id.to_le_bytes())
            .await?;
        reply_writer.write_u32(self.start_from).await?;
        reply_writer.write_u32(self.number_returned).await?;
        for doc in &self.documents {
            let mut s = Vec::new();
            doc.to_writer(&mut s)?;
            reply_writer.write_all(&s).await?;
        }
        let total_length = Header::LENGTH + reply_writer.len();
        header.length = total_length as i32;
        let mut writer = BufWriter::new(stream);
        header.write_to(&mut writer).await?;
        writer.write_all(&reply_writer).await?;
        writer.flush().await?;
        Ok(())
    }
/// Serializes the Message to bytes and writes them to `writer`.
Serializes the Message to bytes and writes them to `writer`.
Serializes the Message to bytes and writes them to ` writer ` .
pub async fn write_to<T: AsyncWrite + Unpin + Send>(
        &self,
        mut header: Header,
        stream: &mut T,
    ) -> Result<()> {
        let mut reply_writer = Vec::new();
        reply_writer.write_u32(self.flags.bits()).await?;
        reply_writer
            .write_all(&self.cursor_id.to_le_bytes())
            .await?;
        reply_writer.write_u32(self.start_from).await?;
        reply_writer.write_u32(self.number_returned).await?;
        for doc in &self.documents {
            let mut s = Vec::new();
            doc.to_writer(&mut s)?;
            reply_writer.write_all(&s).await?;
        }
        let total_length = Header::LENGTH + reply_writer.len();
        header.length = total_length as i32;
        let mut writer = BufWriter::new(stream);
        header.write_to(&mut writer).await?;
        writer.write_all(&reply_writer).await?;
        writer.flush().await?;
        Ok(())
    }
pub async fn write_to < T : AsyncWrite + Unpin + Send > ( & self , mut header : Header , stream : & mut T , ) -> Result < ( ) > { let mut reply_writer = Vec :: new ( ) ; reply_writer . write_u32 ( self . flags . bits ( ) ) . await ? ; reply_writer . write_all ( & self . cursor_id . to_le_bytes ( ) ) . await ? ; reply_writer . write_u32 ( self . start_from ) . await ? ; reply_writer . write_u32 ( self . number_returned ) . await ? ; for doc in & self . documents { let mut s = Vec :: new ( ) ; doc . to_writer ( & mut s ) ? ; reply_writer . write_all ( & s ) . await ? ; } let total_length = Header :: LENGTH + reply_writer . len ( ) ; header . length = total_length as i32 ; let mut writer = BufWriter :: new ( stream ) ; header . write_to ( & mut writer ) . await ? ; writer . write_all ( & reply_writer ) . await ? ; writer . flush ( ) . await ? ; Ok ( ( ) ) }
Serializes the Message to bytes and writes them to `writer`.
Serializes the Message to bytes and writes them to ` writer ` .
&self
header
Header
stream
&mut T
&self
header
Header
stream
&mut T