pub fn pack(
        &mut self,
        msg: Vec<u8>,
        compression: &mut Option<HashMap<String, usize>>,
        compression_off: usize,
    ) -> Result<Vec<u8>, Error> {
        if let Some(body) = &self.body {
            self.header.typ = body.real_type();
        } else {
            return Err(ERR_NIL_RESOURCE_BODY.to_owned());
        }
        let (mut msg, len_off) = self.header.pack(msg, compression, compression_off)?;
        let pre_len = msg.len();
        if let Some(body) = &self.body {
            msg = body.pack(msg, compression, compression_off)?;
            self.header.fix_len(&mut msg, len_off, pre_len)?;
        }
        Ok(msg)
    }
// pack appends the wire format of the Resource to msg.
pack appends the wire format of the Resource to msg.
pack appends the wire format of the Resource to msg .
pub fn pack(
        &mut self,
        msg: Vec<u8>,
        compression: &mut Option<HashMap<String, usize>>,
        compression_off: usize,
    ) -> Result<Vec<u8>, Error> {
        if let Some(body) = &self.body {
            self.header.typ = body.real_type();
        } else {
            return Err(ERR_NIL_RESOURCE_BODY.to_owned());
        }
        let (mut msg, len_off) = self.header.pack(msg, compression, compression_off)?;
        let pre_len = msg.len();
        if let Some(body) = &self.body {
            msg = body.pack(msg, compression, compression_off)?;
            self.header.fix_len(&mut msg, len_off, pre_len)?;
        }
        Ok(msg)
    }
pub fn pack ( & mut self , msg : Vec < u8 > , compression : & mut Option < HashMap < String , usize > > , compression_off : usize , ) -> Result < Vec < u8 > , Error > { if let Some ( body ) = & self . body { self . header . typ = body . real_type ( ) ; } else { return Err ( ERR_NIL_RESOURCE_BODY . to_owned ( ) ) ; } let ( mut msg , len_off ) = self . header . pack ( msg , compression , compression_off ) ? ; let pre_len = msg . len ( ) ; if let Some ( body ) = & self . body { msg = body . pack ( msg , compression , compression_off ) ? ; self . header . fix_len ( & mut msg , len_off , pre_len ) ? ; } Ok ( msg ) }
pack appends the wire format of the Resource to msg.
pack appends the wire format of the Resource to msg .
&mut self
msg
Vec<u8>
compression
&mut Option<HashMap<String, usize>>
compression_off
usize
&mut self
msg
Vec<u8>
compression
&mut Option<HashMap<String, usize>>
compression_off
usize