pub fn serialize(target: &Target, p: &Prog, buf: &mut [u8]) -> Result<usize, SerializeError> {
    let mut ctx = ExecCtx {
        target,
        buf,
        res_args: HashMap::default(),
        copyout_seq: 0,
        eof: false,
    };

    for call in p.calls() {
        ctx.serialize_call(call);
    }
    ctx.write_u64(EXEC_INSTR_EOF);

    if !ctx.buf.has_remaining_mut() || ctx.eof || ctx.copyout_seq > EXEC_MAX_COMMANDS {
        Err(SerializeError::BufferTooSmall {
            provided: buf.len(),
        })
    } else {
        Ok(ctx.buf.remaining_mut())
    }
}
/// Serialize a prog into packed binary format.
Serialize a prog into packed binary format.
Serialize a prog into packed binary format .
pub fn serialize(target: &Target, p: &Prog, buf: &mut [u8]) -> Result<usize, SerializeError> {
    let mut ctx = ExecCtx {
        target,
        buf,
        res_args: HashMap::default(),
        copyout_seq: 0,
        eof: false,
    };
    for call in p.calls() {
        ctx.serialize_call(call);
    }
    ctx.write_u64(EXEC_INSTR_EOF);
    if !ctx.buf.has_remaining_mut() || ctx.eof || ctx.copyout_seq > EXEC_MAX_COMMANDS {
        Err(SerializeError::BufferTooSmall {
            provided: buf.len(),
        })
    } else {
        Ok(ctx.buf.remaining_mut())
    }
}
pub fn serialize ( target : & Target , p : & Prog , buf : & mut [ u8 ] ) -> Result < usize , SerializeError > { let mut ctx = ExecCtx { target , buf , res_args : HashMap :: default ( ) , copyout_seq : 0 , eof : false , } ; for call in p . calls ( ) { ctx . serialize_call ( call ) ; } ctx . write_u64 ( EXEC_INSTR_EOF ) ; if ! ctx . buf . has_remaining_mut ( ) || ctx . eof || ctx . copyout_seq > EXEC_MAX_COMMANDS { Err ( SerializeError :: BufferTooSmall { provided : buf . len ( ) , } ) } else { Ok ( ctx . buf . remaining_mut ( ) ) } }
Serialize a prog into packed binary format.
Serialize a prog into packed binary format .
target
&Target
p
&Prog
buf
&mut [u8]
target
&Target
p
&Prog
buf
&mut [u8]