pub fn new(chunk_size: ChunkSize, payload: Vec<u8>) -> Result<Self, io::Error> {
        if chunk_size.size() == 0 {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "Chunk size cannot be zero",
            ));
        }

        let size = chunk_size.size() as u64;
        let num_chunks = ((payload.len() as u64 + size as u64 - 1) / size) as u8;

        if num_chunks > 128 {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "Number of chunks exceeds 128",
            ));
        }

        let id = ChunkedMessageId::random();

        Ok(ChunkedMessage {
            chunk_size,
            payload,
            num_chunks,
            id,
        })
    }
/// Several sanity checks are performed on construction:
/// - chunk_size must be greater than 0
/// - GELF allows for a maximum of 128 chunks per message
Several sanity checks are performed on construction:
chunk_size must be greater than 0
GELF allows for a maximum of 128 chunks per message
Several sanity checks are performed on construction : chunk_size must be greater than 0 GELF allows for a maximum of 128 chunks per message
pub fn new(chunk_size: ChunkSize, payload: Vec<u8>) -> Result<Self, io::Error> {
        if chunk_size.size() == 0 {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "Chunk size cannot be zero",
            ));
        }
        let size = chunk_size.size() as u64;
        let num_chunks = ((payload.len() as u64 + size as u64 - 1) / size) as u8;
        if num_chunks > 128 {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "Number of chunks exceeds 128",
            ));
        }
        let id = ChunkedMessageId::random();
        Ok(ChunkedMessage {
            chunk_size,
            payload,
            num_chunks,
            id,
        })
    }
pub fn new ( chunk_size : ChunkSize , payload : Vec < u8 > ) -> Result < Self , io :: Error > { if chunk_size . size ( ) == 0 { return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) ; } let size = chunk_size . size ( ) as u64 ; let num_chunks = ( ( payload . len ( ) as u64 + size as u64 - 1 ) / size ) as u8 ; if num_chunks > 128 { return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) ; } let id = ChunkedMessageId :: random ( ) ; Ok ( ChunkedMessage { chunk_size , payload , num_chunks , id , } ) }
Several sanity checks are performed on construction:
 chunk_size must be greater than 0
 GELF allows for a maximum of 128 chunks per message
Several sanity checks are performed on construction : chunk_size must be greater than 0 GELF allows for a maximum of 128 chunks per message
chunk_size
ChunkSize
payload
Vec<u8>