pub fn encode(&self) -> (Vec<u8>, usize) {
        let mut buffer: Vec<u8> = vec![];
        let mut len = buffer.len();
        //let cursor = self.fields[0].start_byte;
        for field in &self.fields {
            /* if (field.startByte != byteCursor) {
                throw new WfCoreException("Invalid field order while encoding: did not expect field " + field.debugInfo() + " at byte " + byteCursor, null);
            } */
            let field_length = field.bit_length();
            //buffer.appendBits(field.encode(), field.bitLength());
            buffer = super::wf_codec::common::concatinate_bits(
                &buffer,
                len,
                &field.encode().expect("field had no value"),
                field_length,
            );

            len += field_length;
            //byteCursor = field.endByte;
        }

        (buffer, len)
    }
/**
     * Encodes this message segment
     * @return a binary buffer with the binary encoded message segment and its bit length
     * @throws WfCoreException if the message cannot be encoded
     */
Encodes this message segment
@return a binary buffer with the binary encoded message segment and its bit length
@throws WfCoreException if the message cannot be encoded
Encodes this message segment @return a binary buffer with the binary encoded message segment and its bit length @throws WfCoreException if the message cannot be encoded
pub fn encode(&self) -> (Vec<u8>, usize) {
        let mut buffer: Vec<u8> = vec![];
        let mut len = buffer.len();
        //let cursor = self.fields[0].start_byte;
        for field in &self.fields {
            /* if (field.startByte != byteCursor) {
                throw new WfCoreException("Invalid field order while encoding: did not expect field " + field.debugInfo() + " at byte " + byteCursor, null);
            } */
            let field_length = field.bit_length();
            //buffer.appendBits(field.encode(), field.bitLength());
            buffer = super::wf_codec::common::concatinate_bits(
                &buffer,
                len,
                &field.encode().expect("field had no value"),
                field_length,
            );
            len += field_length;
            //byteCursor = field.endByte;
        }
        (buffer, len)
    }
pub fn encode ( & self ) -> ( Vec < u8 > , usize ) { let mut buffer : Vec < u8 > = vec ! [ ] ; let mut len = buffer . len ( ) ; //let cursor = self.fields[0].start_byte; for field in & self . fields { /* if (field.startByte != byteCursor) {
                throw new WfCoreException("Invalid field order while encoding: did not expect field " + field.debugInfo() + " at byte " + byteCursor, null);
            } */ let field_length = field . bit_length ( ) ; //buffer.appendBits(field.encode(), field.bitLength()); buffer = super :: wf_codec :: common :: concatinate_bits ( & buffer , len , & field . encode ( ) . expect ( " " ) , field_length , ) ; len += field_length ; //byteCursor = field.endByte; } ( buffer , len ) }
Encodes this message segment
 @return a binary buffer with the binary encoded message segment and its bit length
 @throws WfCoreException if the message cannot be encoded
Encodes this message segment @return a binary buffer with the binary encoded message segment and its bit length @throws WfCoreException if the message cannot be encoded
&self
&self