fn pad(data: &[u8], length: u16) -> Result<Bytes, Error> {
    // The fact that FIDL bindings require mutable data when sending a packet means we need to
    // define packets as the full length instead of only defining a packet as the meaningful
    // payload and iterating over additional fixed zero bytes to form the full length.
    //
    // Defining padded packets requires a copy operatation (unlike the other zero-copy
    // initializers) and so we define padding methods that use byte array references.
    if data.len() > length as usize {
        return Err(format_err!("Data to pad exceeded requested length"));
    }
    let mut bytes = Bytes::with_capacity(length as usize);
    bytes.extend(data);
    bytes.extend(&vec![0; length as usize]);
    Ok(bytes)
}
/// Convenience method to create a new `Bytes` with the supplied input padded with zeros.
Convenience method to create a new `Bytes` with the supplied input padded with zeros.
Convenience method to create a new ` Bytes ` with the supplied input padded with zeros .
fn pad(data: &[u8], length: u16) -> Result<Bytes, Error> {
    // The fact that FIDL bindings require mutable data when sending a packet means we need to
    // define packets as the full length instead of only defining a packet as the meaningful
    // payload and iterating over additional fixed zero bytes to form the full length.
    //
    // Defining padded packets requires a copy operatation (unlike the other zero-copy
    // initializers) and so we define padding methods that use byte array references.
    if data.len() > length as usize {
        return Err(format_err!("Data to pad exceeded requested length"));
    }
    let mut bytes = Bytes::with_capacity(length as usize);
    bytes.extend(data);
    bytes.extend(&vec![0; length as usize]);
    Ok(bytes)
}
fn pad ( data : & [ u8 ] , length : u16 ) -> Result < Bytes , Error > { // The fact that FIDL bindings require mutable data when sending a packet means we need to // define packets as the full length instead of only defining a packet as the meaningful // payload and iterating over additional fixed zero bytes to form the full length. // // Defining padded packets requires a copy operatation (unlike the other zero-copy // initializers) and so we define padding methods that use byte array references. if data . len ( ) > length as usize { return Err ( format_err ! ( " " ) ) ; } let mut bytes = Bytes :: with_capacity ( length as usize ) ; bytes . extend ( data ) ; bytes . extend ( & vec ! [ 0 length as usize ] ) ; Ok ( bytes ) }
Convenience method to create a new `Bytes` with the supplied input padded with zeros.
Convenience method to create a new ` Bytes ` with the supplied input padded with zeros .
data
&[u8]
length
u16