MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / assert_expected_layout

Function assert_expected_layout

crates/table/src/static_layout.rs:431–453  ·  view source on GitHub ↗
(ty: ProductType, bsatn_length: u16, fields: &[(u16, u16, u16)])

Source from the content-addressed store, hash-verified

429 use spacetimedb_sats::{bsatn, proptest::generate_typed_row, AlgebraicType, ProductType};
430
431 fn assert_expected_layout(ty: ProductType, bsatn_length: u16, fields: &[(u16, u16, u16)]) {
432 let expected_layout = StaticLayout {
433 bsatn_length,
434 fields: fields
435 .iter()
436 .copied()
437 .map(|(bflatn_offset, bsatn_offset, length)| MemcpyField {
438 bflatn_offset,
439 bsatn_offset,
440 length,
441 })
442 .collect::<SmallVec<_>>()
443 .into(),
444 };
445 let row_type = RowTypeLayout::from(ty.clone());
446 let Some(computed_layout) = StaticLayout::for_row_type(&row_type) else {
447 panic!("assert_expected_layout: Computed `None` for row {row_type:#?}\nExpected:{expected_layout:#?}");
448 };
449 assert_eq!(
450 computed_layout, expected_layout,
451 "assert_expected_layout: Computed layout (left) doesn't match expected (right) for {ty:?}",
452 );
453 }
454
455 #[test]
456 fn known_types_expected_layout_plain() {

Calls 3

iterMethod · 0.65
mapMethod · 0.45
cloneMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…