You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's very common to serialize an obj as SBE, when obj having a field of String type (or similar) while SBE defining it as fixed length primitive array.
When encoding a field of fixed length primitive array type, one must:
first construct an array
copy bytes into this array
pass this array to Encoder and copy bytes into its backing ByteBuf
It may be more convenient to generate a new method copy from directly slice ref.
For example, there exists a field named "account" of char[16].
Currently it generates a method called "account" with parameter of type &[u8; 16].
Following method is proposed to be generated as well:
pubfnaccount_from_slice_ref(&mutself,value:&[u8]){// Typical implementationlet offset = self.offset;let buf = self.get_buf_mut();let len = value.len();// How to deal with cases input slice is too large: quietly copy leading bytes of fixed size or return Result or panic ?if len > 16{
buf.put_slice_at(offset,&value[..16]);}else{
buf.put_slice_at(offset, value);// Padding with ZERO
buf.put_u8_at(len + 0,0_u8);}}
The text was updated successfully, but these errors were encountered:
It's very common to serialize an obj as SBE, when obj having a field of String type (or similar) while SBE defining it as fixed length primitive array.
When encoding a field of fixed length primitive array type, one must:
It may be more convenient to generate a new method copy from directly slice ref.
For example, there exists a field named "account" of char[16].
Currently it generates a method called "account" with parameter of type
&[u8; 16]
.Following method is proposed to be generated as well:
The text was updated successfully, but these errors were encountered: