Skip to content

A way to store a byte array #37

@rubend056

Description

@rubend056

Is there a way to store a byte array of a specific size?

I'm asking because I wanted to implement the ToRecord trait for my own struct Limb:

impl ToRecord for &Limb {
	fn store(&self, buf: &mut std::vec::Vec<u8>) {
		buf.write(&postcard::to_vec::<_, 32>(self).unwrap()).unwrap();
	}
	fn format_char(&self) -> u8 {
		b'L'
	}
	fn size(&self) -> usize {
		32
	}
	fn variable_size(&self) -> bool {
		false
	}
}

but I got a panic on row_format.rs on line 151:
panic!("invalid format character '{}'", a);

There seems to be more to extending the formats stored than just implementing ToRecord/FromRecord. Is there an easier way to do this? Or should I just use 's' with base64 encoding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions