Skip to content

Commit 67d932e

Browse files
committed
idol: Support byte array params to hubpack encoded idol ops (#430)
1 parent 6049a84 commit 67d932e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

humility-idol/src/lib.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,41 @@ fn serialize_arg(
610610
bail!("non-newtype structure arguments currently unsupported");
611611
}
612612
}
613+
HubrisType::Array(&HubrisArray { goff, count }) => {
614+
let t = hubris.lookup_type(goff)?;
615+
if !matches!(
616+
t,
617+
HubrisType::Base(HubrisBasetype {
618+
encoding: HubrisEncoding::Unsigned,
619+
size: 1,
620+
})
621+
) {
622+
bail!(
623+
"array type in {} ({t:?}) not yet supported",
624+
member.name
625+
);
626+
}
627+
match value {
628+
IdolArgument::String(value) => {
629+
let bytes = bytes_from_str(value)?;
630+
if bytes.len() != count {
631+
bail!(
632+
"Cannot convert '{value}' to [u8; {count}]; \
633+
wrong length"
634+
);
635+
}
636+
637+
for byte in bytes {
638+
hubpack_serialize_append(buf, &byte)?;
639+
}
640+
641+
Ok(())
642+
}
643+
_ => {
644+
bail!("Bad idol argument value");
645+
}
646+
}
647+
}
613648
_ => {
614649
bail!("type of {} ({:?}) not yet supported", member.name, t);
615650
}

0 commit comments

Comments
 (0)