Implement generated packet wire codecs (#47)
Some checks failed
Native code generation / deterministic (push) Successful in 4m29s
Imaging and meshing gate / native (push) Failing after 16s
JPEG 2000 feature / linux (push) Failing after 59s
Skia feature / linux (push) Failing after 1m37s

This commit is contained in:
2026-08-09 08:16:32 +00:00
parent 5bc22bdd83
commit 74801c3488
16 changed files with 87505 additions and 25470 deletions

View File

@@ -985,6 +985,7 @@ def validate_generated_shims() -> None:
"crate::json_codec::",
"crate::notation::",
"crate::packet_catalog::",
"crate::packet_wire::",
"crate::protobuf::",
"crate::xml_codec::",
)
@@ -1156,9 +1157,8 @@ def method_receiver(owner: dict, item: dict) -> tuple[str, str]:
return "&self", "shared_self"
if owner["doc_id"] == "T:LibreMetaverse.BitPack" and item["name"].startswith(("Pack", "Unpack")):
return "&mut self", "mutable_self"
if (
owner["doc_id"] == "T:LibreMetaverse.Packets.InventoryDescendentsPacket"
and item["name"].startswith("FromBytes")
if owner["doc_id"].startswith("T:LibreMetaverse.Packets.") and item["name"].startswith(
"FromBytes"
):
return "&mut self", "mutable_self"
observers = ("Get", "TryGet", "Find", "Contains", "Has", "Is", "Can", "To", "Equals", "Compare")
@@ -1215,6 +1215,17 @@ def member_signature(mapper: Mapper, owner: dict, item: dict, rust_name: str) ->
return signature, ownership, "sync", "Result<_, crate::Error>", "method"
generics = generic_names(item, owner)
mapped_parameters = [map_parameter(mapper, parameter, generics) for parameter in item.get("parameters", [])]
packet_owner = owner["doc_id"].startswith("T:LibreMetaverse.Packets.")
if (
packet_owner
and item["name"] == "FromBytes"
and len(mapped_parameters) == 4
and item["doc_id"].endswith(",System.Byte[])")
):
mapped_parameters[3] = ("optional_mutable_borrow", "zero_buffer: Option<&mut [u8]>")
if packet_owner and item["name"] in {"AcksToBytes", "ToBytes"} and mapped_parameters:
if owner["doc_id"] == "T:LibreMetaverse.Packets.Header" or owner["doc_id"].endswith("Block"):
mapped_parameters[0] = ("mutable_borrow", "bytes: &mut [u8]")
own = [value[0] for value in mapped_parameters]
parameters = ", ".join(value[1] for value in mapped_parameters)
kind = item["kind"]