Catalog-member vectors: element ids on the record and arm types a list needs (fix batch 2)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-27 22:36:17 +01:00
commit 749c52e29d
2 changed files with 25 additions and 16 deletions

View file

@ -14,18 +14,24 @@ struct CatalogMemberMark {
label: String,
#[cultcache(key = 1)]
weight: i32,
#[cultcache(key = 2)]
id: String,
}
#[derive(Clone, Debug, PartialEq, CultSlots)]
struct CatalogMemberTextArm {
#[cultcache(key = 0)]
text: String,
#[cultcache(key = 1)]
id: String,
}
#[derive(Clone, Debug, PartialEq, CultSlots)]
struct CatalogMemberCountArm {
#[cultcache(key = 0)]
count: i32,
#[cultcache(key = 1)]
id: String,
}
#[derive(Clone, Debug, PartialEq, CultUnion)]
@ -150,21 +156,21 @@ fn expected() -> CatalogMembers {
raw: vec![0, 1, 2, 254, 255],
chunks: vec![serde_bytes::ByteBuf::from(vec![9, 8]), serde_bytes::ByteBuf::from(vec![7])],
weights: [("brass".to_string(), 12), ("glass".to_string(), 3)].into_iter().collect(),
mark: CatalogMemberMark { label: "stamp".into(), weight: 5 },
arm: CatalogMemberArm::Count(CatalogMemberCountArm { count: 21 }),
mark: CatalogMemberMark { label: "stamp".into(), weight: 5, id: "0000000000a0".into() },
arm: CatalogMemberArm::Count(CatalogMemberCountArm { count: 21, id: "0000000000a1".into() }),
late: -9_000_000_000,
items: vec![CatalogMemberMark { label: "i0".into(), weight: 1 }, CatalogMemberMark { label: "i1".into(), weight: 2 }],
marks: vec![CatalogMemberMark { label: "m0".into(), weight: 3 }],
items: vec![CatalogMemberMark { label: "i0".into(), weight: 1, id: "0000000000b0".into() }, CatalogMemberMark { label: "i1".into(), weight: 2, id: "0000000000b1".into() }],
marks: vec![CatalogMemberMark { label: "m0".into(), weight: 3, id: "0000000000c0".into() }],
by_label: [
("x".to_string(), CatalogMemberMark { label: "bx".into(), weight: 4 }),
("y".to_string(), CatalogMemberMark { label: "by".into(), weight: 5 }),
("x".to_string(), CatalogMemberMark { label: "bx".into(), weight: 4, id: "0000000000d0".into() }),
("y".to_string(), CatalogMemberMark { label: "by".into(), weight: 5, id: "0000000000d1".into() }),
]
.into_iter()
.collect(),
maybe_mark: Some(CatalogMemberMark { label: "maybe".into(), weight: 6 }),
maybe_mark: Some(CatalogMemberMark { label: "maybe".into(), weight: 6, id: "0000000000e0".into() }),
arms: vec![
CatalogMemberArm::Text(CatalogMemberTextArm { text: "t".into() }),
CatalogMemberArm::Count(CatalogMemberCountArm { count: 8 }),
CatalogMemberArm::Text(CatalogMemberTextArm { text: "t".into(), id: "0000000000f0".into() }),
CatalogMemberArm::Count(CatalogMemberCountArm { count: 8, id: "0000000000f1".into() }),
],
grid: vec![vec![1, 2], vec![3]],
by_number: [(-1, "neg".to_string()), (7, "seven".to_string())].into_iter().collect(),

View file

@ -15,6 +15,7 @@ namespace GameCult.Caching.Tests
{
[Key(0)] public string Label = string.Empty;
[Key(1)] public int Weight;
[Key(2)] [CultElementId] public string Id = string.Empty;
}
[Union(0, typeof(CatalogMemberTextArm))]
@ -25,12 +26,14 @@ namespace GameCult.Caching.Tests
public sealed class CatalogMemberTextArm : CatalogMemberArm
{
[Key(0)] public string Text = string.Empty;
[Key(1)] [CultElementId] public string Id = string.Empty;
}
[MessagePackObject]
public sealed class CatalogMemberCountArm : CatalogMemberArm
{
[Key(0)] public int Count;
[Key(1)] [CultElementId] public string Id = string.Empty;
}
public enum CatalogMemberKind
@ -102,14 +105,14 @@ namespace GameCult.Caching.Tests
Raw = new byte[] { 0, 1, 2, 254, 255 },
Chunks = new List<byte[]> { new byte[] { 9, 8 }, new byte[] { 7 } },
Weights = new Dictionary<string, int> { ["brass"] = 12, ["glass"] = 3 },
Mark = new CatalogMemberMark { Label = "stamp", Weight = 5 },
Arm = new CatalogMemberCountArm { Count = 21 },
Mark = new CatalogMemberMark { Label = "stamp", Weight = 5, Id = "0000000000a0" },
Arm = new CatalogMemberCountArm { Count = 21, Id = "0000000000a1" },
Late = -9_000_000_000L,
Items = new List<CatalogMemberMark> { new() { Label = "i0", Weight = 1 }, new() { Label = "i1", Weight = 2 } },
Marks = new[] { new CatalogMemberMark { Label = "m0", Weight = 3 } },
ByLabel = new Dictionary<string, CatalogMemberMark> { ["x"] = new() { Label = "bx", Weight = 4 }, ["y"] = new() { Label = "by", Weight = 5 } },
MaybeMark = new CatalogMemberMark { Label = "maybe", Weight = 6 },
Arms = new List<CatalogMemberArm> { new CatalogMemberTextArm { Text = "t" }, new CatalogMemberCountArm { Count = 8 } },
Items = new List<CatalogMemberMark> { new() { Label = "i0", Weight = 1, Id = "0000000000b0" }, new() { Label = "i1", Weight = 2, Id = "0000000000b1" } },
Marks = new[] { new CatalogMemberMark { Label = "m0", Weight = 3, Id = "0000000000c0" } },
ByLabel = new Dictionary<string, CatalogMemberMark> { ["x"] = new() { Label = "bx", Weight = 4, Id = "0000000000d0" }, ["y"] = new() { Label = "by", Weight = 5, Id = "0000000000d1" } },
MaybeMark = new CatalogMemberMark { Label = "maybe", Weight = 6, Id = "0000000000e0" },
Arms = new List<CatalogMemberArm> { new CatalogMemberTextArm { Text = "t", Id = "0000000000f0" }, new CatalogMemberCountArm { Count = 8, Id = "0000000000f1" } },
Grid = new List<List<int>> { new() { 1, 2 }, new() { 3 } },
ByNumber = new Dictionary<int, string> { [-1] = "neg", [7] = "seven" },
Kind = CatalogMemberKind.Fancy,