Open njaard opened 10 months ago
I actually came across another usecase for passing around a Vec<u8>
. I want to create a trait method which returns the result of record()
. This doesn't seem directly possible due to impl Trait
not being a valid return value. I figure I should be able to pass the output of RecordBuilder::store()
to add_record_raw
by replicating this logic here?
https://github.com/njaard/sonnerie/blob/172c301950cdde42bd70bd44b3c6d58373410fc1/src/write.rs#L227C1-L251C5
Or actually just
buf.write_u64::<BigEndian>(1.1e18 as u64).unwrap();
record.store(&mut buf);
should be enough?
Yes to replicating the logic in that function you linked to.
Just storing that 1.1e18 (to represent the timestamp?) isn't enough in the case of storing strings as a payload, because Strings are variable-length encoding.
You can see the length of the entire record is stored as a varint in that case
I had problems with it myself in https://github.com/njaard/sonnerie/issues/28