Skip to content

Instantly share code, notes, and snippets.

@tobz
Created December 2, 2021 19:33
Show Gist options
  • Save tobz/b6f951bd54adc7d9a1aa872635b06b2f to your computer and use it in GitHub Desktop.
Save tobz/b6f951bd54adc7d9a1aa872635b06b2f to your computer and use it in GitHub Desktop.
#[derive(Archive, Serialize, Debug)]
pub struct Record<'a> {
/// The checksum of the record.
///
/// The checksum is CRC32C(big_endian_bytes(id) + payload).
pub(super) checksum: u32,
/// The record ID.
///
/// This is monotonic across records.
id: u64,
// The record length.
//
// This is the number of bytes that follow the header.
#[with(CopyOptimize, RefAsBox)]
payload: &'a [u8],
}
#[rustc_layout(debug)]
#[repr(transparent)]
struct DebugArchivedRecord<'a>(ArchivedRecord<'a>);
layout_of(disk_v2::record::DebugArchivedRecord) = Layout {
fields: Arbitrary {
offsets: [
Size {
raw: 0,
},
],
memory_index: [
0,
],
},
variants: Single {
index: 0,
},
abi: Aggregate {
sized: true,
},
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align {
pow2: 3,
},
pref: Align {
pow2: 3,
},
},
size: Size {
raw: 24,
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment