diff --git a/Cargo.toml b/Cargo.toml index 7e5715c..e966b80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,24 +43,14 @@ build = "build.rs" # Some features may require multiple dependencies to compile properly # For example, benchmarking bincode requires two features: "serde" and "bincode" [dependencies] -abomonation = { version = "=0.7.3", optional = true } -abomonation_derive = { version = "=0.5.0", optional = true } -alkahest = { version = "=0.1.5", optional = true, features = [ - "derive", - "nightly", -] } -bebop = { version = "=2.8.7", optional = true } bilrost = { version = "=0.1010.0", optional = true } bincode1 = { package = "bincode", version = "=1.3.3", optional = true } # Can't call it bincode2 because of a current issue of bincode2 bincode = { package = "bincode", version = "=2.0.0-rc.3", optional = true } -bitcode = { version = "=0.6.0", optional = true } +bitcode = { version = "=0.6.3", optional = true } borsh = { version = "=1.5.1", features = ["derive"], optional = true } -# TODO: Unfork after bson adds support for pre-warmed serialization buffers -# https://github.com/mongodb/bson-rust/pull/328 -bson = { version = "=2.9.0", git = "https://github.com/djkoloski/bson-rust", branch = "add_into_vec", optional = true } -capnp = { version = "=0.19.6", optional = true } -cbor4ii = { version = "=0.3.2", features = [ "use_std", "serde1" ], optional = true } +capnp = { version = "=0.19.7", optional = true } +cbor4ii = { version = "=0.3.3", features = [ "use_std", "serde1" ], optional = true } ciborium = { version = "=0.2.2", optional = true } criterion = "=0.5.1" databuf = { version = "=0.5.0", optional = true } @@ -72,38 +62,33 @@ nachricht-serde = { version = "=0.4.0", optional = true } nanoserde = {version = "=0.1.37", optional = true } parity-scale-codec = { version = "=3.6.12", features = ["full"], optional = true } parity-scale-codec-derive = { version = "=3.6.12", optional = true } -postcard = { version = "=1.0.8", features = ["alloc"], optional = true } -pot = { version = "=3.0.0", optional = true } +postcard = { version = "=1.0.10", features = ["alloc"], optional = true } +pot = { version = "=3.0.1", optional = true } pprof = { version = "=0.13.0", features = ["flamegraph"], optional = true } -prost = { version = "=0.12.6", optional = true } +prost = { version = "=0.13.2", optional = true } rand = "=0.8.5" rkyv = { version = "=0.8.5", optional = true } rmp-serde = { version = "=1.3.0", optional = true } ron = { version = "=0.8.1", optional = true } -serde = { version = "=1.0.204", features = ["derive"], optional = true } +serde = { version = "=1.0.210", features = ["derive"] } serde_bare = { version = "=0.5.0", optional = true } serde_cbor = { version = "=0.11.2", optional = true } -serde_json = { version = "=1.0.120", features = ["float_roundtrip"], optional = true } +serde_json = { version = "=1.0.128", features = ["float_roundtrip"], optional = true } simd-json = { version = "=0.13.10", optional = true } simd-json-derive = { version = "=0.13.0", optional = true } speedy = { version = "=0.8.7", optional = true } -savefile = { version = "=0.17.6", optional = true } -savefile-derive = { version = "=0.17.6", optional = true } +savefile = { version = "=0.17.7", optional = true } +savefile-derive = { version = "=0.17.7", optional = true } wiring = { version = "=0.2.2", optional = true } zstd = "=0.13.2" [features] default = [ - "abomonation", - "abomonation_derive", - "alkahest", - # "bebop", "bilrost", "bincode1", "bincode", "bitcode", "borsh", - "bson", "capnp", "cbor4ii", "ciborium", @@ -120,7 +105,6 @@ default = [ "rkyv", "rmp-serde", "ron", - "serde", "serde_bare", "serde_cbor", "serde_json", @@ -144,11 +128,10 @@ regenerate-prost = ["dep:prost-build"] rand_pcg = "0.3.1" [build-dependencies] -bebop-tools = "=2.8.7" -capnp = "=0.19.6" +capnp = "=0.19.7" capnpc = { version = "=0.19.0", optional = true } flatc-rust = { version = "=0.2.0", optional = true } -prost-build = { version = "=0.12.6", optional = true } +prost-build = { version = "=0.13.2", optional = true } [[bench]] harness = false diff --git a/benches/bench.rs b/benches/bench.rs index da28fd5..ddd6678 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,10 +1,6 @@ #[allow(unused_imports)] use criterion::{black_box, criterion_main, Criterion}; use rand_pcg::Lcg64Xsh32; -#[cfg(feature = "abomonation")] -use rust_serialization_benchmark::bench_abomonation; -#[cfg(feature = "alkahest")] -use rust_serialization_benchmark::bench_alkahest; #[cfg(feature = "bilrost")] use rust_serialization_benchmark::bench_bilrost; #[cfg(feature = "bincode")] @@ -15,8 +11,6 @@ use rust_serialization_benchmark::bench_bincode1; use rust_serialization_benchmark::bench_bitcode; #[cfg(feature = "borsh")] use rust_serialization_benchmark::bench_borsh; -#[cfg(feature = "bson")] -use rust_serialization_benchmark::bench_bson; #[cfg(feature = "capnp")] use rust_serialization_benchmark::bench_capnp; #[cfg(feature = "cbor4ii")] @@ -82,25 +76,6 @@ fn bench_log(c: &mut Criterion) { logs: generate_vec::<_, Log>(&mut rng, LOGS..LOGS + 1), }; - #[cfg(feature = "abomonation")] - bench_abomonation::bench(BENCH, c, &data, |data| { - for log in data.logs.iter() { - black_box(log.address); - black_box(log.code); - black_box(log.size); - } - }); - - // Doesn't use a closure due to ICE in rustc. Probably related to https://github.com/rust-lang/rust/issues/86703 - #[cfg(feature = "alkahest")] - bench_alkahest::bench(BENCH, c, &data, |data| { - for log in data.logs { - black_box(&log.address); - black_box(log.code); - black_box(log.size); - } - }); - #[cfg(feature = "bilrost")] bench_bilrost::bench(BENCH, c, &data); @@ -116,9 +91,6 @@ fn bench_log(c: &mut Criterion) { #[cfg(feature = "borsh")] bench_borsh::bench(BENCH, c, &data); - #[cfg(feature = "bson")] - bench_bson::bench(BENCH, c, &data); - #[cfg(feature = "capnp")] bench_capnp::bench(BENCH, c, &data, |bytes| { let message_reader = @@ -281,21 +253,6 @@ fn bench_mesh(c: &mut Criterion) { triangles: generate_vec::<_, Triangle>(&mut rng, TRIANGLES..TRIANGLES + 1), }; - #[cfg(feature = "abomonation")] - bench_abomonation::bench(BENCH, c, &data, |data| { - for triangle in data.triangles.iter() { - black_box(triangle.normal); - } - }); - - // Doesn't use a closure due to ICE in rustc. Probably related to https://github.com/rust-lang/rust/issues/86703 - #[cfg(feature = "alkahest")] - bench_alkahest::bench(BENCH, c, &data, |mesh| { - for triangle in mesh.triangles { - black_box(&triangle.normal); - } - }); - #[cfg(feature = "bilrost")] bench_bilrost::bench(BENCH, c, &data); @@ -311,9 +268,6 @@ fn bench_mesh(c: &mut Criterion) { #[cfg(feature = "borsh")] bench_borsh::bench(BENCH, c, &data); - #[cfg(feature = "bson")] - bench_bson::bench(BENCH, c, &data); - #[cfg(feature = "capnp")] bench_capnp::bench(BENCH, c, &data, |bytes| { let message_reader = @@ -463,20 +417,6 @@ fn bench_minecraft_savedata(c: &mut Criterion) { players: generate_vec::<_, Player>(&mut rng, PLAYERS..PLAYERS + 1), }; - #[cfg(feature = "abomonation")] - bench_abomonation::bench(BENCH, c, &data, |data| { - for player in data.players.iter() { - black_box(player.game_type); - } - }); - - #[cfg(feature = "alkahest")] - bench_alkahest::bench(BENCH, c, &data, |data| { - for player in data.players { - black_box(&player.game_type); - } - }); - #[cfg(feature = "bilrost")] bench_bilrost::bench(BENCH, c, &data); @@ -492,9 +432,6 @@ fn bench_minecraft_savedata(c: &mut Criterion) { #[cfg(feature = "borsh")] bench_borsh::bench(BENCH, c, &data); - #[cfg(feature = "bson")] - bench_bson::bench(BENCH, c, &data); - #[cfg(feature = "capnp")] bench_capnp::bench(BENCH, c, &data, |bytes| { let message_reader = @@ -647,20 +584,6 @@ fn bench_mk48(c: &mut Criterion) { updates: generate_vec(&mut rng, UPDATES..UPDATES + 1), }; - #[cfg(feature = "abomonation")] - bench_abomonation::bench(BENCH, c, &data, |data| { - for update in data.updates.iter() { - black_box(update.score); - } - }); - - #[cfg(feature = "alkahest")] - bench_alkahest::bench(BENCH, c, &data, |data| { - for update in data.updates { - black_box(update.score); - } - }); - #[cfg(feature = "bilrost")] bench_bilrost::bench(BENCH, c, &data); @@ -676,9 +599,6 @@ fn bench_mk48(c: &mut Criterion) { #[cfg(feature = "borsh")] bench_borsh::bench(BENCH, c, &data); - #[cfg(feature = "bson")] - bench_bson::bench(BENCH, c, &data); - #[cfg(feature = "capnp")] bench_capnp::bench(BENCH, c, &data, |bytes| { let message_reader = diff --git a/build.rs b/build.rs index 9af63cd..0aab62c 100644 --- a/build.rs +++ b/build.rs @@ -4,18 +4,6 @@ use std::{ path::{Path, PathBuf}, }; -// TODO: re-enable bebop -#[allow(dead_code)] -fn bebop_compile_dataset(name: &'static str) { - bebop_tools::download_bebopc(PathBuf::from("target").join("bebopc")); - - bebop_tools::build_schema( - format!("./src/datasets/{0}/{0}.bop", name), - format!("./src/datasets/{0}/{0}_bebop.rs", name), - &bebop_tools::BuildConfig::default(), - ); -} - #[cfg(feature = "regenerate-capnp")] fn capnpc_compile_dataset(name: &'static str) -> capnp::Result<()> { let mut command = capnpc::CompilerCommand::new(); @@ -71,7 +59,6 @@ fn main() { { const DATASETS: &[&str] = &["log", "mesh", "minecraft_savedata", "mk48"]; for &name in DATASETS.iter() { - // bebop_compile_dataset(name); #[cfg(feature = "regenerate-capnp")] capnpc_compile_dataset(name).unwrap(); #[cfg(feature = "regenerate-flatbuffers")] diff --git a/pages/Cargo.toml b/pages/Cargo.toml index 19b40d6..eb29410 100644 --- a/pages/Cargo.toml +++ b/pages/Cargo.toml @@ -22,9 +22,10 @@ features = [ 'HtmlSelectElement', ] -[profile.release] -codegen-units = 1 -lto = true -opt-level = "z" -panic = "abort" -strip = "debuginfo" +# TODO: move this profile to the top level, but without affecting benchmarks? +# [profile.release] +# codegen-units = 1 +# lto = true +# opt-level = "z" +# panic = "abort" +# strip = "debuginfo" diff --git a/rustfmt.toml b/rustfmt.toml index 74e1cc1..b0b637b 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,15 +1,11 @@ # Ignore generated source files ignore = [ - "src/datasets/log/log_bebop.rs", "src/datasets/log/log_capnp.rs", "src/datasets/log/log_generated.rs", - "src/datasets/mesh/mesh_bebop.rs", "src/datasets/mesh/mesh_capnp.rs", "src/datasets/mesh/mesh_generated.rs", - "src/datasets/minecraft_savedata/minecraft_savedata_bebop.rs", "src/datasets/minecraft_savedata/minecraft_savedata_capnp.rs", "src/datasets/minecraft_savedata/minecraft_savedata_generated.rs", - "src/datasets/mk48/mk48_bebop.rs", "src/datasets/mk48/mk48_capnp.rs", "src/datasets/mk48/mk48_generated.rs", ] diff --git a/src/bench_abomonation.rs b/src/bench_abomonation.rs deleted file mode 100644 index bd66156..0000000 --- a/src/bench_abomonation.rs +++ /dev/null @@ -1,60 +0,0 @@ -use abomonation::{decode, encode, Abomonation}; -use criterion::{black_box, Criterion}; - -pub fn bench(name: &'static str, c: &mut Criterion, data: &T, read: R) -where - T: Abomonation + Clone + PartialEq, - R: Fn(&T), -{ - const BUFFER_LEN: usize = 10_000_000; - - let mut group = c.benchmark_group(format!("{}/abomonation", name)); - - let mut serialize_buffer = Vec::with_capacity(BUFFER_LEN); - group.bench_function("serialize", |b| { - b.iter(|| { - serialize_buffer.clear(); - unsafe { - encode(data, black_box(&mut serialize_buffer)).unwrap(); - black_box(()); - } - }) - }); - - let mut deserialize_buffer = Vec::new(); - unsafe { - encode(data, &mut deserialize_buffer).unwrap(); - } - - group.bench_function("access (unvalidated)", |b| { - b.iter(|| unsafe { - black_box(decode::(black_box(&mut deserialize_buffer)).unwrap()); - }) - }); - - group.bench_function("read (unvalidated)", |b| { - b.iter(|| unsafe { - let (data, _) = decode::(black_box(&mut deserialize_buffer)).unwrap(); - read(data); - black_box(()); - }) - }); - - group.bench_function("deserialize (unvalidated)", |b| { - b.iter(|| { - let (data, _) = unsafe { decode::(black_box(&mut deserialize_buffer)).unwrap() }; - black_box((*data).clone()); - }) - }); - - crate::bench_size(name, "abomonation", deserialize_buffer.as_slice()); - - assert!( - unsafe { decode::(black_box(&mut deserialize_buffer)) } - .unwrap() - .0 - == data - ); - - group.finish(); -} diff --git a/src/bench_alkahest.rs b/src/bench_alkahest.rs deleted file mode 100644 index f219ec2..0000000 --- a/src/bench_alkahest.rs +++ /dev/null @@ -1,40 +0,0 @@ -use alkahest::{Pack, Schema, Unpacked}; -use criterion::{black_box, Criterion}; - -pub fn bench(name: &'static str, c: &mut Criterion, data: D, read: fn(Unpacked<'_, T>)) -where - T: Schema, - D: Pack + Copy, -{ - let mut group = c.benchmark_group(format!("{}/alkahest", name)); - - // This leak is required because of ICE in rustc if `R` has bound like this `for<'a> Fn(Unpacked<'a, T>)`. - const BUFFER_LEN: usize = 10_000_000; - let mut buffer = vec![0; BUFFER_LEN]; - - group.bench_function("serialize", |b| { - b.iter(|| { - black_box(alkahest::write::(&mut buffer, black_box(data))); - }) - }); - - let size = alkahest::write::(&mut buffer, data); - let buffer = &buffer[..size]; - - group.bench_function("access (validated on-demand with panic)", |b| { - b.iter(|| { - black_box(alkahest::read::(black_box(buffer))); - }) - }); - - group.bench_function("read (validated on-demand with panic)", |b| { - b.iter(|| { - read(alkahest::read::(black_box(buffer))); - black_box(()); - }) - }); - - crate::bench_size(name, "alkahest", buffer); - - group.finish(); -} diff --git a/src/bench_bincode.rs b/src/bench_bincode.rs index 4213a68..5b26e0e 100644 --- a/src/bench_bincode.rs +++ b/src/bench_bincode.rs @@ -17,7 +17,7 @@ where }) }); - let size = bincode::encode_into_slice(&data, &mut *buffer, conf).unwrap(); + let size = bincode::encode_into_slice(data, &mut *buffer, conf).unwrap(); let buffer = &buffer[..size]; group.bench_function("deserialize", |b| { diff --git a/src/bench_bson.rs b/src/bench_bson.rs deleted file mode 100644 index c8a31f6..0000000 --- a/src/bench_bson.rs +++ /dev/null @@ -1,37 +0,0 @@ -use criterion::{black_box, Criterion}; -use serde::{Deserialize, Serialize}; - -pub fn bench(name: &'static str, c: &mut Criterion, data: &T) -where - T: Serialize + for<'de> Deserialize<'de> + PartialEq, -{ - const BUFFER_LEN: usize = 50_000_000; - - let mut group = c.benchmark_group(format!("{}/bson", name)); - - let mut serialize_buffer = vec![0; BUFFER_LEN]; - group.bench_function("serialize", |b| { - b.iter(|| { - serialize_buffer.clear(); - let mut target_buffer = Vec::new(); - ::core::mem::swap(&mut serialize_buffer, &mut target_buffer); - let mut target_buffer = - black_box(bson::ser::into_vec(black_box(&data), black_box(target_buffer)).unwrap()); - ::core::mem::swap(&mut serialize_buffer, &mut target_buffer); - }) - }); - - let deserialize_buffer = bson::ser::into_vec(&data, Vec::new()).unwrap(); - - group.bench_function("deserialize", |b| { - b.iter(|| { - black_box(bson::from_slice::<'_, T>(black_box(&deserialize_buffer)).unwrap()); - }) - }); - - crate::bench_size(name, "bson", deserialize_buffer.as_slice()); - - assert!(bson::from_slice::(&deserialize_buffer).unwrap() == *data); - - group.finish(); -} diff --git a/src/bench_databuf.rs b/src/bench_databuf.rs index b0ede60..3e8070e 100644 --- a/src/bench_databuf.rs +++ b/src/bench_databuf.rs @@ -13,7 +13,7 @@ where group.bench_function("serialize", |b| { b.iter(|| { serialize_buffer.clear(); - black_box(data.encode::(&mut serialize_buffer)); + data.encode::(&mut serialize_buffer).unwrap(); }) }); diff --git a/src/bench_nachricht_serde.rs b/src/bench_nachricht_serde.rs index b18a43f..074f081 100644 --- a/src/bench_nachricht_serde.rs +++ b/src/bench_nachricht_serde.rs @@ -13,7 +13,7 @@ where group.bench_function("serialize", |b| { b.iter(|| { nachricht_serde::to_writer( - &mut black_box(serialize_buffer.as_mut_slice()), + black_box(serialize_buffer.as_mut_slice()), black_box(&data), ) .unwrap(); diff --git a/src/bench_pot.rs b/src/bench_pot.rs index 0262c48..5df8c52 100644 --- a/src/bench_pot.rs +++ b/src/bench_pot.rs @@ -12,10 +12,7 @@ where let mut serialize_buffer = vec![0; BUFFER_LEN]; group.bench_function("serialize", |b| { b.iter(|| { - black_box( - pot::to_writer(black_box(&data), black_box(serialize_buffer.as_mut_slice())) - .unwrap(), - ); + pot::to_writer(black_box(&data), black_box(serialize_buffer.as_mut_slice())).unwrap(); }) }); diff --git a/src/bench_rkyv.rs b/src/bench_rkyv.rs index 0511fd6..2d4bae3 100644 --- a/src/bench_rkyv.rs +++ b/src/bench_rkyv.rs @@ -51,15 +51,14 @@ where group.bench_function("read (unvalidated)", |b| { b.iter(|| { - black_box(unsafe { read(access_unchecked::(black_box(buffer.as_ref()))) }) + let value = unsafe { access_unchecked::(black_box(buffer.as_ref())) }; + read(value); }) }); group.bench_function("read (validated upfront with error)", |b| { b.iter(|| { - black_box(read( - access::(black_box(buffer.as_ref())).unwrap(), - )) + read(access::(black_box(buffer.as_ref())).unwrap()); }) }); @@ -70,7 +69,6 @@ where access_unchecked_mut::(black_box(update_buffer.as_mut_slice())) }; update(value.as_mut()); - black_box(value); }) }); diff --git a/src/bench_wiring.rs b/src/bench_wiring.rs index 692dee6..6550a90 100644 --- a/src/bench_wiring.rs +++ b/src/bench_wiring.rs @@ -9,7 +9,7 @@ pub fn bench(name: &'static str, c: &mut Crite let mut wire: Vec = Vec::with_capacity(BUFFER_LEN); group.bench_function("serialize", |b| { - b.iter(|| black_box(BufWire::new(&mut wire).wire(black_box(data)).unwrap())) + b.iter(|| BufWire::new(&mut wire).wire(black_box(data)).unwrap()) }); BufWire::new(&mut wire).wire(data).unwrap(); @@ -17,7 +17,7 @@ pub fn bench(name: &'static str, c: &mut Crite let buffer = wire.as_slice(); group.bench_function("deserialize", |b| { - b.iter(|| black_box(BufUnWire::new(black_box(buffer)).unwire::().unwrap())) + b.iter(|| BufUnWire::new(black_box(buffer)).unwire::().unwrap()) }); crate::bench_size(name, "wiring", wire.as_slice()); diff --git a/src/datasets/log/log.bop b/src/datasets/log/log.bop deleted file mode 100644 index 8323072..0000000 --- a/src/datasets/log/log.bop +++ /dev/null @@ -1,20 +0,0 @@ -struct Address { - uint32 x0; - uint32 x1; - uint32 x2; - uint32 x3; -} - -struct Log { - Address address; - string identity; - string userid; - string date; - string request; - uint32 code; - uint64 size; -} - -struct Logs { - Log[] logs_; -} diff --git a/src/datasets/log/log_bebop.rs b/src/datasets/log/log_bebop.rs deleted file mode 100644 index 8f6fdbc..0000000 --- a/src/datasets/log/log_bebop.rs +++ /dev/null @@ -1,347 +0,0 @@ -// -// This code was generated by a tool. -// -// -// bebopc version: -// 2.8.5 -// -// -// bebopc source: -// https://github.com/RainwayApp/bebop -// -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// - -#![allow(warnings)] - -use bebop::FixedSized as _; -use core::convert::TryInto as _; -use std::io::Write as _; - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Address { - pub x0: u32, - pub x1: u32, - pub x2: u32, - pub x3: u32, -} - -impl ::bebop::FixedSized for Address {} - -impl<'raw> ::bebop::SubRecord<'raw> for Address { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x0)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.x1)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.x2)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.x3)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - x0: v0, - x1: v1, - x2: v2, - x3: v3, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Address {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Log<'raw> { - pub address: Address, - pub identity: &'raw str, - pub userid: &'raw str, - pub date: &'raw str, - pub request: &'raw str, - pub code: u32, - pub size: u64, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Log<'raw> { - const MIN_SERIALIZED_SIZE: usize =
::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.address.serialized_size() - + self.identity.serialized_size() - + self.userid.serialized_size() - + self.date.serialized_size() - + self.request.serialized_size() - + self.code.serialized_size() - + self.size.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.address._serialize_chained(dest)? + - zelf.identity._serialize_chained(dest)? + - zelf.userid._serialize_chained(dest)? + - zelf.date._serialize_chained(dest)? + - zelf.request._serialize_chained(dest)? + - zelf.code._serialize_chained(dest)? + - zelf.size._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - address: v0, - identity: v1, - userid: v2, - date: v3, - request: v4, - code: v5, - size: v6, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Log<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Logs<'raw> { - pub logs_: ::std::vec::Vec>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Logs<'raw> { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.logs_.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.logs_._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { logs_: v0 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for Logs<'raw> {} - -#[cfg(feature = "bebop-owned-all")] -pub mod owned { - #![allow(warnings)] - - use bebop::FixedSized as _; - use core::convert::TryInto as _; - use std::io::Write as _; - - pub use super::Address; - - #[derive(Clone, Debug, PartialEq)] - pub struct Log { - pub address: Address, - pub identity: String, - pub userid: String, - pub date: String, - pub request: String, - pub code: u32, - pub size: u64, - } - - impl<'raw> ::core::convert::From> for Log { - fn from(value: super::Log) -> Self { - Self { - address: value.address, - identity: value.identity.into(), - userid: value.userid.into(), - date: value.date.into(), - request: value.request.into(), - code: value.code, - size: value.size, - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Log { - const MIN_SERIALIZED_SIZE: usize =
::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.address.serialized_size() - + self.identity.serialized_size() - + self.userid.serialized_size() - + self.date.serialized_size() - + self.request.serialized_size() - + self.code.serialized_size() - + self.size.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.address._serialize_chained(dest)? + - zelf.identity._serialize_chained(dest)? + - zelf.userid._serialize_chained(dest)? + - zelf.date._serialize_chained(dest)? + - zelf.request._serialize_chained(dest)? + - zelf.code._serialize_chained(dest)? + - zelf.size._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - address: v0, - identity: v1, - userid: v2, - date: v3, - request: v4, - code: v5, - size: v6, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Log {} - - #[derive(Clone, Debug, PartialEq)] - pub struct Logs { - pub logs_: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for Logs { - fn from(value: super::Logs) -> Self { - Self { - logs_: value.logs_.into_iter().map(|value| value.into()).collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Logs { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.logs_.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.logs_._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { logs_: v0 })) - } - } - - impl<'raw> ::bebop::Record<'raw> for Logs {} -} diff --git a/src/datasets/log/mod.rs b/src/datasets/log/mod.rs index f6972a1..f41f734 100644 --- a/src/datasets/log/mod.rs +++ b/src/datasets/log/mod.rs @@ -1,10 +1,8 @@ -#[cfg(feature = "bebop")] -pub mod log_bebop; #[cfg(feature = "capnp")] pub mod log_capnp; #[cfg(feature = "flatbuffers")] #[path = "log_generated.rs"] -#[allow(unused_imports)] +#[allow(unused_imports, clippy::all)] pub mod log_fb; #[cfg(feature = "prost")] #[path = "prost.log.rs"] @@ -31,7 +29,6 @@ use crate::bench_prost; use crate::Generate; #[derive(Clone, Copy, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -46,7 +43,7 @@ use crate::Generate; derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -56,7 +53,6 @@ use crate::Generate; derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring))] pub struct Address { @@ -83,10 +79,10 @@ impl Generate for Address { } #[cfg(feature = "flatbuffers")] -impl Into for Address { +impl From
for fb::Address { #[inline] - fn into(self) -> fb::Address { - fb::Address::new(self.x0, self.x1, self.x2, self.x3) + fn from(value: Address) -> Self { + Self::new(value.x0, value.x1, value.x2, value.x3) } } @@ -110,12 +106,12 @@ impl bench_prost::Serialize for Address { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.x0 = self.x0 as u32; - result.x1 = self.x1 as u32; - result.x2 = self.x2 as u32; - result.x3 = self.x3 as u32; - result + Self::Message { + x0: self.x0 as u32, + x1: self.x1 as u32, + x2: self.x2 as u32, + x3: self.x3 as u32, + } } } @@ -131,22 +127,7 @@ impl From for Address { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack
for Address { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed
, usize) { - AddressPack { - x0: self.x0, - x1: self.x1, - x2: self.x2, - x3: self.x3, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -160,7 +141,7 @@ impl alkahest::Pack
for Address { feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -184,18 +165,6 @@ pub struct Log { pub size: u64, } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct LogSchema { - pub address: Address, - pub identity: alkahest::Bytes, - pub userid: alkahest::Bytes, - pub date: alkahest::Bytes, - pub request: alkahest::Bytes, - pub code: u16, - pub size: u64, -} - impl Generate for Log { fn generate(rand: &mut R) -> Self { const USERID: [&str; 9] = [ @@ -335,25 +304,7 @@ impl From for Log { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Log { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - LogSchemaPack { - address: self.address, - identity: self.identity.as_bytes(), - userid: self.userid.as_bytes(), - date: self.date.as_bytes(), - request: self.request.as_bytes(), - code: self.code, - size: self.size, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -367,7 +318,7 @@ impl alkahest::Pack for &'_ Log { feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -442,20 +393,3 @@ impl From for Logs { } } } - -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct LogsSchema { - pub logs: alkahest::Seq, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Logs { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - LogsSchemaPack { - logs: self.logs.iter(), - } - .pack(offset, output) - } -} diff --git a/src/datasets/mesh/mesh.bop b/src/datasets/mesh/mesh.bop deleted file mode 100644 index bc37df6..0000000 --- a/src/datasets/mesh/mesh.bop +++ /dev/null @@ -1,16 +0,0 @@ -struct Vector3 { - float32 x; - float32 y; - float32 z; -} - -struct Triangle { - Vector3 v0; - Vector3 v1; - Vector3 v2; - Vector3 normal; -} - -struct Mesh { - Triangle[] triangles; -} diff --git a/src/datasets/mesh/mesh_bebop.rs b/src/datasets/mesh/mesh_bebop.rs deleted file mode 100644 index 402e661..0000000 --- a/src/datasets/mesh/mesh_bebop.rs +++ /dev/null @@ -1,225 +0,0 @@ -// -// This code was generated by a tool. -// -// -// bebopc version: -// 2.8.5 -// -// -// bebopc source: -// https://github.com/RainwayApp/bebop -// -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// - -#![allow(warnings)] - -use bebop::FixedSized as _; -use core::convert::TryInto as _; -use std::io::Write as _; - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Vector3 { - pub x: f32, - pub y: f32, - pub z: f32, -} - -impl ::bebop::FixedSized for Vector3 {} - -impl<'raw> ::bebop::SubRecord<'raw> for Vector3 { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.y)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.z)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - x: v0, - y: v1, - z: v2, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Vector3 {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Triangle { - pub v0: Vector3, - pub v1: Vector3, - pub v2: Vector3, - pub normal: Vector3, -} - -impl ::bebop::FixedSized for Triangle {} - -impl<'raw> ::bebop::SubRecord<'raw> for Triangle { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.v0)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.v1)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.v2)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.normal)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - v0: v0, - v1: v1, - v2: v2, - normal: v3, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Triangle {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Mesh<'raw> { - pub triangles: ::bebop::SliceWrapper<'raw, Triangle>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Mesh<'raw> { - const MIN_SERIALIZED_SIZE: usize = <::bebop::SliceWrapper<'raw, Triangle>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.triangles.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.triangles._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { triangles: v0 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for Mesh<'raw> {} - -#[cfg(feature = "bebop-owned-all")] -pub mod owned { - #![allow(warnings)] - - use bebop::FixedSized as _; - use core::convert::TryInto as _; - use std::io::Write as _; - - pub use super::Vector3; - - pub use super::Triangle; - - #[derive(Clone, Debug, PartialEq)] - pub struct Mesh { - pub triangles: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for Mesh { - fn from(value: super::Mesh) -> Self { - Self { - triangles: value.triangles.iter().map(|value| value).collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Mesh { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.triangles.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.triangles._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { triangles: v0 })) - } - } - - impl<'raw> ::bebop::Record<'raw> for Mesh {} -} diff --git a/src/datasets/mesh/mod.rs b/src/datasets/mesh/mod.rs index bd56e55..d5a5f70 100644 --- a/src/datasets/mesh/mod.rs +++ b/src/datasets/mesh/mod.rs @@ -2,7 +2,7 @@ pub mod mesh_capnp; #[cfg(feature = "flatbuffers")] #[path = "mesh_generated.rs"] -#[allow(unused_imports)] +#[allow(unused_imports, clippy::all)] pub mod mesh_fb; #[cfg(feature = "prost")] #[path = "prost.mesh.rs"] @@ -29,7 +29,6 @@ use crate::bench_prost; use crate::Generate; #[derive(Clone, Copy, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -47,13 +46,12 @@ use crate::Generate; feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring))] @@ -75,10 +73,10 @@ impl Generate for Vector3 { } #[cfg(feature = "flatbuffers")] -impl Into for Vector3 { +impl From for fb::Vector3 { #[inline] - fn into(self) -> fb::Vector3 { - fb::Vector3::new(self.x, self.y, self.z) + fn from(value: Vector3) -> Self { + Self::new(value.x, value.y, value.z) } } @@ -101,11 +99,11 @@ impl bench_prost::Serialize for Vector3 { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.x = self.x; - result.y = self.y; - result.z = self.z; - result + Self::Message { + x: self.x, + y: self.y, + z: self.z, + } } } @@ -120,21 +118,7 @@ impl From for Vector3 { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for Vector3 { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - Vector3Pack { - x: self.x, - y: self.y, - z: self.z, - } - .pack(offset, output) - } -} - #[derive(Clone, Copy, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -152,13 +136,12 @@ impl alkahest::Pack for Vector3 { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring))] @@ -182,14 +165,14 @@ impl Generate for Triangle { } #[cfg(feature = "flatbuffers")] -impl Into for Triangle { +impl From for fb::Triangle { #[inline] - fn into(self) -> fb::Triangle { - fb::Triangle::new( - &self.v0.into(), - &self.v1.into(), - &self.v2.into(), - &self.normal.into(), + fn from(value: Triangle) -> Self { + Self::new( + &value.v0.into(), + &value.v1.into(), + &value.v2.into(), + &value.normal.into(), ) } } @@ -215,12 +198,12 @@ impl bench_prost::Serialize for Triangle { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.v0 = Some(self.v0.serialize_pb()); - result.v1 = Some(self.v1.serialize_pb()); - result.v2 = Some(self.v2.serialize_pb()); - result.normal = Some(self.normal.serialize_pb()); - result + Self::Message { + v0: Some(self.v0.serialize_pb()), + v1: Some(self.v1.serialize_pb()), + v2: Some(self.v2.serialize_pb()), + normal: Some(self.normal.serialize_pb()), + } } } @@ -236,22 +219,7 @@ impl From for Triangle { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Triangle { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - TrianglePack { - v0: self.v0, - v1: self.v1, - v2: self.v2, - normal: self.normal, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -269,7 +237,7 @@ impl alkahest::Pack for &'_ Triangle { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -342,20 +310,3 @@ impl From for Mesh { } } } - -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct MeshSchema { - pub triangles: alkahest::Seq, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Mesh { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - MeshSchemaPack { - triangles: self.triangles.iter(), - } - .pack(offset, output) - } -} diff --git a/src/datasets/minecraft_savedata/minecraft_savedata.bop b/src/datasets/minecraft_savedata/minecraft_savedata.bop deleted file mode 100644 index 2591c04..0000000 --- a/src/datasets/minecraft_savedata/minecraft_savedata.bop +++ /dev/null @@ -1,112 +0,0 @@ -enum GameType { - SURVIVAL = 0; - CREATIVE = 1; - ADVENTURE = 2; - SPECTATOR = 3; -} - -struct Item { - int32 count; - uint32 slot; - string id; -} - -struct Abilities { - float32 walk_speed; - float32 fly_speed; - bool may_fly; - bool flying; - bool invulnerable; - bool may_build; - bool instabuild; -} - -struct Vector3d { - float64 x; - float64 y; - float64 z; -} - -struct Vector2f { - float32 x; - float32 y; -} - -struct Uuid { - uint32 x0; - uint32 x1; - uint32 x2; - uint32 x3; -} - -struct Entity { - string id; - Vector3d pos; - Vector3d motion; - Vector2f rotation; - float32 fall_distance; - uint32 fire; - uint32 air; - bool on_ground; - bool no_gravity; - bool invulnerable; - int32 portal_cooldown; - Uuid uuid; - string custom_name; - bool custom_name_visible; - bool silent; - bool glowing; -} - -struct RecipeBook { - string[] recipes; - string[] to_be_displayed; - bool is_filtering_craftable; - bool is_gui_open; - bool is_furnace_filtering_craftable; - bool is_furnace_gui_open; - bool is_blasting_furnace_filtering_craftable; - bool is_blasting_furnace_gui_open; - bool is_smoker_filtering_craftable; - bool is_smoker_gui_open; -} - -struct Vehicle { - Uuid uuid; - Entity entity; -} - -struct Player { - GameType game_type; - GameType previous_game_type; - int64 score; - string dimension; - uint32 selected_item_slot; - Item selected_item; - string spawn_dimension; - int64 spawn_x; - int64 spawn_y; - int64 spawn_z; - bool spawn_forced; - uint32 sleep_timer; - float32 food_exhaustion_level; - float32 food_saturation_level; - uint32 food_tick_timer; - uint32 xp_level; - float32 xp_p; - int32 xp_total; - int32 xp_seed; - Item[] inventory; - Item[] ender_items; - Abilities abilities; - Vector3d entered_nether_position; - Vehicle root_vehicle; - Entity shoulder_entity_left; - Entity shoulder_entity_right; - bool seen_credits; - RecipeBook recipe_book; -} - -struct Players { - Player[] players_; -} \ No newline at end of file diff --git a/src/datasets/minecraft_savedata/minecraft_savedata_bebop.rs b/src/datasets/minecraft_savedata/minecraft_savedata_bebop.rs deleted file mode 100644 index 50cbef2..0000000 --- a/src/datasets/minecraft_savedata/minecraft_savedata_bebop.rs +++ /dev/null @@ -1,1675 +0,0 @@ -// -// This code was generated by a tool. -// -// -// bebopc version: -// 2.8.5 -// -// -// bebopc source: -// https://github.com/RainwayApp/bebop -// -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// - -#![allow(warnings)] - -use bebop::FixedSized as _; -use core::convert::TryInto as _; -use std::io::Write as _; - -#[repr(u32)] -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum GameType { - Survival = 0, - Creative = 1, - Adventure = 2, - Spectator = 3, -} - -impl ::core::convert::TryFrom for GameType { - type Error = ::bebop::DeserializeError; - - fn try_from(value: u32) -> ::bebop::DeResult { - match value { - 0 => Ok(GameType::Survival), - 1 => Ok(GameType::Creative), - 2 => Ok(GameType::Adventure), - 3 => Ok(GameType::Spectator), - d => Err(::bebop::DeserializeError::InvalidEnumDiscriminator( - d.into(), - )), - } - } -} - -impl ::core::convert::From for u32 { - fn from(value: GameType) -> Self { - match value { - GameType::Survival => 0, - GameType::Creative => 1, - GameType::Adventure => 2, - GameType::Spectator => 3, - } - } -} - -impl ::bebop::SubRecord<'_> for GameType { - const MIN_SERIALIZED_SIZE: usize = ::std::mem::size_of::(); - const EXACT_SERIALIZED_SIZE: Option = Some(::std::mem::size_of::()); - - #[inline] - fn serialized_size(&self) -> usize { - ::std::mem::size_of::() - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - u32::from(zelf)._serialize_chained(dest) - }); - - #[inline] - fn _deserialize_chained(raw: &[u8]) -> ::bebop::DeResult<(usize, Self)> { - let (n, v) = u32::_deserialize_chained(raw)?; - Ok((n, v.try_into()?)) - } -} - -impl ::bebop::FixedSized for GameType { - const SERIALIZED_SIZE: usize = ::std::mem::size_of::(); -} - -#[derive(Clone, Debug, PartialEq)] -pub struct Item<'raw> { - pub count: i32, - pub slot: u32, - pub id: &'raw str, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Item<'raw> { - const MIN_SERIALIZED_SIZE: usize = - ::MIN_SERIALIZED_SIZE + ::MIN_SERIALIZED_SIZE + <&'raw str>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.count.serialized_size() + self.slot.serialized_size() + self.id.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.count._serialize_chained(dest)? + - zelf.slot._serialize_chained(dest)? + - zelf.id._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - count: v0, - slot: v1, - id: v2, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Item<'raw> {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Abilities { - pub walk_speed: f32, - pub fly_speed: f32, - pub may_fly: bool, - pub flying: bool, - pub invulnerable: bool, - pub may_build: bool, - pub instabuild: bool, -} - -impl ::bebop::FixedSized for Abilities {} - -impl<'raw> ::bebop::SubRecord<'raw> for Abilities { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.walk_speed)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.fly_speed)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.may_fly)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.flying)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.invulnerable)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.may_build)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.instabuild)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - walk_speed: v0, - fly_speed: v1, - may_fly: v2, - flying: v3, - invulnerable: v4, - may_build: v5, - instabuild: v6, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Abilities {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Vector3D { - pub x: f64, - pub y: f64, - pub z: f64, -} - -impl ::bebop::FixedSized for Vector3D {} - -impl<'raw> ::bebop::SubRecord<'raw> for Vector3D { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.y)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.z)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - x: v0, - y: v1, - z: v2, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Vector3D {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Vector2F { - pub x: f32, - pub y: f32, -} - -impl ::bebop::FixedSized for Vector2F {} - -impl<'raw> ::bebop::SubRecord<'raw> for Vector2F { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.y)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { x: v0, y: v1 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for Vector2F {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Uuid { - pub x0: u32, - pub x1: u32, - pub x2: u32, - pub x3: u32, -} - -impl ::bebop::FixedSized for Uuid {} - -impl<'raw> ::bebop::SubRecord<'raw> for Uuid { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x0)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.x1)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.x2)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.x3)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - x0: v0, - x1: v1, - x2: v2, - x3: v3, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Uuid {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Entity<'raw> { - pub id: &'raw str, - pub pos: Vector3d, - pub motion: Vector3d, - pub rotation: Vector2f, - pub fall_distance: f32, - pub fire: u32, - pub air: u32, - pub on_ground: bool, - pub no_gravity: bool, - pub invulnerable: bool, - pub portal_cooldown: i32, - pub uuid: Uuid, - pub custom_name: &'raw str, - pub custom_name_visible: bool, - pub silent: bool, - pub glowing: bool, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Entity<'raw> { - const MIN_SERIALIZED_SIZE: usize = <&'raw str>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.id.serialized_size() - + self.pos.serialized_size() - + self.motion.serialized_size() - + self.rotation.serialized_size() - + self.fall_distance.serialized_size() - + self.fire.serialized_size() - + self.air.serialized_size() - + self.on_ground.serialized_size() - + self.no_gravity.serialized_size() - + self.invulnerable.serialized_size() - + self.portal_cooldown.serialized_size() - + self.uuid.serialized_size() - + self.custom_name.serialized_size() - + self.custom_name_visible.serialized_size() - + self.silent.serialized_size() - + self.glowing.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.id._serialize_chained(dest)? + - zelf.pos._serialize_chained(dest)? + - zelf.motion._serialize_chained(dest)? + - zelf.rotation._serialize_chained(dest)? + - zelf.fall_distance._serialize_chained(dest)? + - zelf.fire._serialize_chained(dest)? + - zelf.air._serialize_chained(dest)? + - zelf.on_ground._serialize_chained(dest)? + - zelf.no_gravity._serialize_chained(dest)? + - zelf.invulnerable._serialize_chained(dest)? + - zelf.portal_cooldown._serialize_chained(dest)? + - zelf.uuid._serialize_chained(dest)? + - zelf.custom_name._serialize_chained(dest)? + - zelf.custom_name_visible._serialize_chained(dest)? + - zelf.silent._serialize_chained(dest)? + - zelf.glowing._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v8) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v9) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v10) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v11) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v12) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v13) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v14) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v15) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - id: v0, - pos: v1, - motion: v2, - rotation: v3, - fall_distance: v4, - fire: v5, - air: v6, - on_ground: v7, - no_gravity: v8, - invulnerable: v9, - portal_cooldown: v10, - uuid: v11, - custom_name: v12, - custom_name_visible: v13, - silent: v14, - glowing: v15, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Entity<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct RecipeBook<'raw> { - pub recipes: ::std::vec::Vec<&'raw str>, - pub to_be_displayed: ::std::vec::Vec<&'raw str>, - pub is_filtering_craftable: bool, - pub is_gui_open: bool, - pub is_furnace_filtering_craftable: bool, - pub is_furnace_gui_open: bool, - pub is_blasting_furnace_filtering_craftable: bool, - pub is_blasting_furnace_gui_open: bool, - pub is_smoker_filtering_craftable: bool, - pub is_smoker_gui_open: bool, -} - -impl<'raw> ::bebop::SubRecord<'raw> for RecipeBook<'raw> { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec<&'raw str>>::MIN_SERIALIZED_SIZE - + <::std::vec::Vec<&'raw str>>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.recipes.serialized_size() - + self.to_be_displayed.serialized_size() - + self.is_filtering_craftable.serialized_size() - + self.is_gui_open.serialized_size() - + self.is_furnace_filtering_craftable.serialized_size() - + self.is_furnace_gui_open.serialized_size() - + self - .is_blasting_furnace_filtering_craftable - .serialized_size() - + self.is_blasting_furnace_gui_open.serialized_size() - + self.is_smoker_filtering_craftable.serialized_size() - + self.is_smoker_gui_open.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.recipes._serialize_chained(dest)? + - zelf.to_be_displayed._serialize_chained(dest)? + - zelf.is_filtering_craftable._serialize_chained(dest)? + - zelf.is_gui_open._serialize_chained(dest)? + - zelf.is_furnace_filtering_craftable._serialize_chained(dest)? + - zelf.is_furnace_gui_open._serialize_chained(dest)? + - zelf.is_blasting_furnace_filtering_craftable._serialize_chained(dest)? + - zelf.is_blasting_furnace_gui_open._serialize_chained(dest)? + - zelf.is_smoker_filtering_craftable._serialize_chained(dest)? + - zelf.is_smoker_gui_open._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v8) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v9) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - recipes: v0, - to_be_displayed: v1, - is_filtering_craftable: v2, - is_gui_open: v3, - is_furnace_filtering_craftable: v4, - is_furnace_gui_open: v5, - is_blasting_furnace_filtering_craftable: v6, - is_blasting_furnace_gui_open: v7, - is_smoker_filtering_craftable: v8, - is_smoker_gui_open: v9, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for RecipeBook<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Vehicle<'raw> { - pub uuid: Uuid, - pub entity: Entity<'raw>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Vehicle<'raw> { - const MIN_SERIALIZED_SIZE: usize = - ::MIN_SERIALIZED_SIZE + >::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.uuid.serialized_size() + self.entity.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.uuid._serialize_chained(dest)? + - zelf.entity._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - uuid: v0, - entity: v1, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Vehicle<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Player<'raw> { - pub game_type: GameType, - pub previous_game_type: GameType, - pub score: i64, - pub dimension: &'raw str, - pub selected_item_slot: u32, - pub selected_item: Item<'raw>, - pub spawn_dimension: &'raw str, - pub spawn_x: i64, - pub spawn_y: i64, - pub spawn_z: i64, - pub spawn_forced: bool, - pub sleep_timer: u32, - pub food_exhaustion_level: f32, - pub food_saturation_level: f32, - pub food_tick_timer: u32, - pub xp_level: u32, - pub xp_p: f32, - pub xp_total: i32, - pub xp_seed: i32, - pub inventory: ::std::vec::Vec>, - pub ender_items: ::std::vec::Vec>, - pub abilities: Abilities, - pub entered_nether_position: Vector3d, - pub root_vehicle: Vehicle<'raw>, - pub shoulder_entity_left: Entity<'raw>, - pub shoulder_entity_right: Entity<'raw>, - pub seen_credits: bool, - pub recipe_book: RecipeBook<'raw>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Player<'raw> { - const MIN_SERIALIZED_SIZE: usize = ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + >::MIN_SERIALIZED_SIZE - + <&'raw str>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>>::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + >::MIN_SERIALIZED_SIZE - + >::MIN_SERIALIZED_SIZE - + >::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + >::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.game_type.serialized_size() - + self.previous_game_type.serialized_size() - + self.score.serialized_size() - + self.dimension.serialized_size() - + self.selected_item_slot.serialized_size() - + self.selected_item.serialized_size() - + self.spawn_dimension.serialized_size() - + self.spawn_x.serialized_size() - + self.spawn_y.serialized_size() - + self.spawn_z.serialized_size() - + self.spawn_forced.serialized_size() - + self.sleep_timer.serialized_size() - + self.food_exhaustion_level.serialized_size() - + self.food_saturation_level.serialized_size() - + self.food_tick_timer.serialized_size() - + self.xp_level.serialized_size() - + self.xp_p.serialized_size() - + self.xp_total.serialized_size() - + self.xp_seed.serialized_size() - + self.inventory.serialized_size() - + self.ender_items.serialized_size() - + self.abilities.serialized_size() - + self.entered_nether_position.serialized_size() - + self.root_vehicle.serialized_size() - + self.shoulder_entity_left.serialized_size() - + self.shoulder_entity_right.serialized_size() - + self.seen_credits.serialized_size() - + self.recipe_book.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.game_type._serialize_chained(dest)? + - zelf.previous_game_type._serialize_chained(dest)? + - zelf.score._serialize_chained(dest)? + - zelf.dimension._serialize_chained(dest)? + - zelf.selected_item_slot._serialize_chained(dest)? + - zelf.selected_item._serialize_chained(dest)? + - zelf.spawn_dimension._serialize_chained(dest)? + - zelf.spawn_x._serialize_chained(dest)? + - zelf.spawn_y._serialize_chained(dest)? + - zelf.spawn_z._serialize_chained(dest)? + - zelf.spawn_forced._serialize_chained(dest)? + - zelf.sleep_timer._serialize_chained(dest)? + - zelf.food_exhaustion_level._serialize_chained(dest)? + - zelf.food_saturation_level._serialize_chained(dest)? + - zelf.food_tick_timer._serialize_chained(dest)? + - zelf.xp_level._serialize_chained(dest)? + - zelf.xp_p._serialize_chained(dest)? + - zelf.xp_total._serialize_chained(dest)? + - zelf.xp_seed._serialize_chained(dest)? + - zelf.inventory._serialize_chained(dest)? + - zelf.ender_items._serialize_chained(dest)? + - zelf.abilities._serialize_chained(dest)? + - zelf.entered_nether_position._serialize_chained(dest)? + - zelf.root_vehicle._serialize_chained(dest)? + - zelf.shoulder_entity_left._serialize_chained(dest)? + - zelf.shoulder_entity_right._serialize_chained(dest)? + - zelf.seen_credits._serialize_chained(dest)? + - zelf.recipe_book._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v8) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v9) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v10) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v11) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v12) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v13) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v14) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v15) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v16) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v17) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v18) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v19) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v20) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v21) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v22) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v23) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v24) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v25) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v26) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v27) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - game_type: v0, - previous_game_type: v1, - score: v2, - dimension: v3, - selected_item_slot: v4, - selected_item: v5, - spawn_dimension: v6, - spawn_x: v7, - spawn_y: v8, - spawn_z: v9, - spawn_forced: v10, - sleep_timer: v11, - food_exhaustion_level: v12, - food_saturation_level: v13, - food_tick_timer: v14, - xp_level: v15, - xp_p: v16, - xp_total: v17, - xp_seed: v18, - inventory: v19, - ender_items: v20, - abilities: v21, - entered_nether_position: v22, - root_vehicle: v23, - shoulder_entity_left: v24, - shoulder_entity_right: v25, - seen_credits: v26, - recipe_book: v27, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Player<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Players<'raw> { - pub players_: ::std::vec::Vec>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Players<'raw> { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.players_.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.players_._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { players_: v0 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for Players<'raw> {} - -#[cfg(feature = "bebop-owned-all")] -pub mod owned { - #![allow(warnings)] - - use bebop::FixedSized as _; - use core::convert::TryInto as _; - use std::io::Write as _; - - pub use super::GameType; - - #[derive(Clone, Debug, PartialEq)] - pub struct Item { - pub count: i32, - pub slot: u32, - pub id: String, - } - - impl<'raw> ::core::convert::From> for Item { - fn from(value: super::Item) -> Self { - Self { - count: value.count, - slot: value.slot, - id: value.id.into(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Item { - const MIN_SERIALIZED_SIZE: usize = - ::MIN_SERIALIZED_SIZE + ::MIN_SERIALIZED_SIZE + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.count.serialized_size() + self.slot.serialized_size() + self.id.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.count._serialize_chained(dest)? + - zelf.slot._serialize_chained(dest)? + - zelf.id._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - count: v0, - slot: v1, - id: v2, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Item {} - - pub use super::Abilities; - - pub use super::Vector3D; - - pub use super::Vector2F; - - pub use super::Uuid; - - #[derive(Clone, Debug, PartialEq)] - pub struct Entity { - pub id: String, - pub pos: Vector3d, - pub motion: Vector3d, - pub rotation: Vector2f, - pub fall_distance: f32, - pub fire: u32, - pub air: u32, - pub on_ground: bool, - pub no_gravity: bool, - pub invulnerable: bool, - pub portal_cooldown: i32, - pub uuid: Uuid, - pub custom_name: String, - pub custom_name_visible: bool, - pub silent: bool, - pub glowing: bool, - } - - impl<'raw> ::core::convert::From> for Entity { - fn from(value: super::Entity) -> Self { - Self { - id: value.id.into(), - pos: value.pos, - motion: value.motion, - rotation: value.rotation, - fall_distance: value.fall_distance, - fire: value.fire, - air: value.air, - on_ground: value.on_ground, - no_gravity: value.no_gravity, - invulnerable: value.invulnerable, - portal_cooldown: value.portal_cooldown, - uuid: value.uuid, - custom_name: value.custom_name.into(), - custom_name_visible: value.custom_name_visible, - silent: value.silent, - glowing: value.glowing, - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Entity { - const MIN_SERIALIZED_SIZE: usize = ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.id.serialized_size() - + self.pos.serialized_size() - + self.motion.serialized_size() - + self.rotation.serialized_size() - + self.fall_distance.serialized_size() - + self.fire.serialized_size() - + self.air.serialized_size() - + self.on_ground.serialized_size() - + self.no_gravity.serialized_size() - + self.invulnerable.serialized_size() - + self.portal_cooldown.serialized_size() - + self.uuid.serialized_size() - + self.custom_name.serialized_size() - + self.custom_name_visible.serialized_size() - + self.silent.serialized_size() - + self.glowing.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.id._serialize_chained(dest)? + - zelf.pos._serialize_chained(dest)? + - zelf.motion._serialize_chained(dest)? + - zelf.rotation._serialize_chained(dest)? + - zelf.fall_distance._serialize_chained(dest)? + - zelf.fire._serialize_chained(dest)? + - zelf.air._serialize_chained(dest)? + - zelf.on_ground._serialize_chained(dest)? + - zelf.no_gravity._serialize_chained(dest)? + - zelf.invulnerable._serialize_chained(dest)? + - zelf.portal_cooldown._serialize_chained(dest)? + - zelf.uuid._serialize_chained(dest)? + - zelf.custom_name._serialize_chained(dest)? + - zelf.custom_name_visible._serialize_chained(dest)? + - zelf.silent._serialize_chained(dest)? + - zelf.glowing._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v8) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v9) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v10) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v11) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v12) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v13) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v14) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v15) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - id: v0, - pos: v1, - motion: v2, - rotation: v3, - fall_distance: v4, - fire: v5, - air: v6, - on_ground: v7, - no_gravity: v8, - invulnerable: v9, - portal_cooldown: v10, - uuid: v11, - custom_name: v12, - custom_name_visible: v13, - silent: v14, - glowing: v15, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Entity {} - - #[derive(Clone, Debug, PartialEq)] - pub struct RecipeBook { - pub recipes: ::std::vec::Vec, - pub to_be_displayed: ::std::vec::Vec, - pub is_filtering_craftable: bool, - pub is_gui_open: bool, - pub is_furnace_filtering_craftable: bool, - pub is_furnace_gui_open: bool, - pub is_blasting_furnace_filtering_craftable: bool, - pub is_blasting_furnace_gui_open: bool, - pub is_smoker_filtering_craftable: bool, - pub is_smoker_gui_open: bool, - } - - impl<'raw> ::core::convert::From> for RecipeBook { - fn from(value: super::RecipeBook) -> Self { - Self { - recipes: value - .recipes - .into_iter() - .map(|value| value.into()) - .collect(), - to_be_displayed: value - .to_be_displayed - .into_iter() - .map(|value| value.into()) - .collect(), - is_filtering_craftable: value.is_filtering_craftable, - is_gui_open: value.is_gui_open, - is_furnace_filtering_craftable: value.is_furnace_filtering_craftable, - is_furnace_gui_open: value.is_furnace_gui_open, - is_blasting_furnace_filtering_craftable: value - .is_blasting_furnace_filtering_craftable, - is_blasting_furnace_gui_open: value.is_blasting_furnace_gui_open, - is_smoker_filtering_craftable: value.is_smoker_filtering_craftable, - is_smoker_gui_open: value.is_smoker_gui_open, - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for RecipeBook { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.recipes.serialized_size() - + self.to_be_displayed.serialized_size() - + self.is_filtering_craftable.serialized_size() - + self.is_gui_open.serialized_size() - + self.is_furnace_filtering_craftable.serialized_size() - + self.is_furnace_gui_open.serialized_size() - + self - .is_blasting_furnace_filtering_craftable - .serialized_size() - + self.is_blasting_furnace_gui_open.serialized_size() - + self.is_smoker_filtering_craftable.serialized_size() - + self.is_smoker_gui_open.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.recipes._serialize_chained(dest)? + - zelf.to_be_displayed._serialize_chained(dest)? + - zelf.is_filtering_craftable._serialize_chained(dest)? + - zelf.is_gui_open._serialize_chained(dest)? + - zelf.is_furnace_filtering_craftable._serialize_chained(dest)? + - zelf.is_furnace_gui_open._serialize_chained(dest)? + - zelf.is_blasting_furnace_filtering_craftable._serialize_chained(dest)? + - zelf.is_blasting_furnace_gui_open._serialize_chained(dest)? + - zelf.is_smoker_filtering_craftable._serialize_chained(dest)? + - zelf.is_smoker_gui_open._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v8) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v9) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - recipes: v0, - to_be_displayed: v1, - is_filtering_craftable: v2, - is_gui_open: v3, - is_furnace_filtering_craftable: v4, - is_furnace_gui_open: v5, - is_blasting_furnace_filtering_craftable: v6, - is_blasting_furnace_gui_open: v7, - is_smoker_filtering_craftable: v8, - is_smoker_gui_open: v9, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for RecipeBook {} - - #[derive(Clone, Debug, PartialEq)] - pub struct Vehicle { - pub uuid: Uuid, - pub entity: Entity, - } - - impl<'raw> ::core::convert::From> for Vehicle { - fn from(value: super::Vehicle) -> Self { - Self { - uuid: value.uuid, - entity: value.entity.into(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Vehicle { - const MIN_SERIALIZED_SIZE: usize = - ::MIN_SERIALIZED_SIZE + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.uuid.serialized_size() + self.entity.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.uuid._serialize_chained(dest)? + - zelf.entity._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - uuid: v0, - entity: v1, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Vehicle {} - - #[derive(Clone, Debug, PartialEq)] - pub struct Player { - pub game_type: GameType, - pub previous_game_type: GameType, - pub score: i64, - pub dimension: String, - pub selected_item_slot: u32, - pub selected_item: Item, - pub spawn_dimension: String, - pub spawn_x: i64, - pub spawn_y: i64, - pub spawn_z: i64, - pub spawn_forced: bool, - pub sleep_timer: u32, - pub food_exhaustion_level: f32, - pub food_saturation_level: f32, - pub food_tick_timer: u32, - pub xp_level: u32, - pub xp_p: f32, - pub xp_total: i32, - pub xp_seed: i32, - pub inventory: ::std::vec::Vec, - pub ender_items: ::std::vec::Vec, - pub abilities: Abilities, - pub entered_nether_position: Vector3d, - pub root_vehicle: Vehicle, - pub shoulder_entity_left: Entity, - pub shoulder_entity_right: Entity, - pub seen_credits: bool, - pub recipe_book: RecipeBook, - } - - impl<'raw> ::core::convert::From> for Player { - fn from(value: super::Player) -> Self { - Self { - game_type: value.game_type, - previous_game_type: value.previous_game_type, - score: value.score, - dimension: value.dimension.into(), - selected_item_slot: value.selected_item_slot, - selected_item: value.selected_item.into(), - spawn_dimension: value.spawn_dimension.into(), - spawn_x: value.spawn_x, - spawn_y: value.spawn_y, - spawn_z: value.spawn_z, - spawn_forced: value.spawn_forced, - sleep_timer: value.sleep_timer, - food_exhaustion_level: value.food_exhaustion_level, - food_saturation_level: value.food_saturation_level, - food_tick_timer: value.food_tick_timer, - xp_level: value.xp_level, - xp_p: value.xp_p, - xp_total: value.xp_total, - xp_seed: value.xp_seed, - inventory: value - .inventory - .into_iter() - .map(|value| value.into()) - .collect(), - ender_items: value - .ender_items - .into_iter() - .map(|value| value.into()) - .collect(), - abilities: value.abilities, - entered_nether_position: value.entered_nether_position, - root_vehicle: value.root_vehicle.into(), - shoulder_entity_left: value.shoulder_entity_left.into(), - shoulder_entity_right: value.shoulder_entity_right.into(), - seen_credits: value.seen_credits, - recipe_book: value.recipe_book.into(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Player { - const MIN_SERIALIZED_SIZE: usize = ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.game_type.serialized_size() - + self.previous_game_type.serialized_size() - + self.score.serialized_size() - + self.dimension.serialized_size() - + self.selected_item_slot.serialized_size() - + self.selected_item.serialized_size() - + self.spawn_dimension.serialized_size() - + self.spawn_x.serialized_size() - + self.spawn_y.serialized_size() - + self.spawn_z.serialized_size() - + self.spawn_forced.serialized_size() - + self.sleep_timer.serialized_size() - + self.food_exhaustion_level.serialized_size() - + self.food_saturation_level.serialized_size() - + self.food_tick_timer.serialized_size() - + self.xp_level.serialized_size() - + self.xp_p.serialized_size() - + self.xp_total.serialized_size() - + self.xp_seed.serialized_size() - + self.inventory.serialized_size() - + self.ender_items.serialized_size() - + self.abilities.serialized_size() - + self.entered_nether_position.serialized_size() - + self.root_vehicle.serialized_size() - + self.shoulder_entity_left.serialized_size() - + self.shoulder_entity_right.serialized_size() - + self.seen_credits.serialized_size() - + self.recipe_book.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.game_type._serialize_chained(dest)? + - zelf.previous_game_type._serialize_chained(dest)? + - zelf.score._serialize_chained(dest)? + - zelf.dimension._serialize_chained(dest)? + - zelf.selected_item_slot._serialize_chained(dest)? + - zelf.selected_item._serialize_chained(dest)? + - zelf.spawn_dimension._serialize_chained(dest)? + - zelf.spawn_x._serialize_chained(dest)? + - zelf.spawn_y._serialize_chained(dest)? + - zelf.spawn_z._serialize_chained(dest)? + - zelf.spawn_forced._serialize_chained(dest)? + - zelf.sleep_timer._serialize_chained(dest)? + - zelf.food_exhaustion_level._serialize_chained(dest)? + - zelf.food_saturation_level._serialize_chained(dest)? + - zelf.food_tick_timer._serialize_chained(dest)? + - zelf.xp_level._serialize_chained(dest)? + - zelf.xp_p._serialize_chained(dest)? + - zelf.xp_total._serialize_chained(dest)? + - zelf.xp_seed._serialize_chained(dest)? + - zelf.inventory._serialize_chained(dest)? + - zelf.ender_items._serialize_chained(dest)? + - zelf.abilities._serialize_chained(dest)? + - zelf.entered_nether_position._serialize_chained(dest)? + - zelf.root_vehicle._serialize_chained(dest)? + - zelf.shoulder_entity_left._serialize_chained(dest)? + - zelf.shoulder_entity_right._serialize_chained(dest)? + - zelf.seen_credits._serialize_chained(dest)? + - zelf.recipe_book._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v8) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v9) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v10) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v11) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v12) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v13) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v14) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v15) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v16) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v17) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v18) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v19) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v20) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v21) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v22) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v23) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v24) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v25) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v26) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v27) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - game_type: v0, - previous_game_type: v1, - score: v2, - dimension: v3, - selected_item_slot: v4, - selected_item: v5, - spawn_dimension: v6, - spawn_x: v7, - spawn_y: v8, - spawn_z: v9, - spawn_forced: v10, - sleep_timer: v11, - food_exhaustion_level: v12, - food_saturation_level: v13, - food_tick_timer: v14, - xp_level: v15, - xp_p: v16, - xp_total: v17, - xp_seed: v18, - inventory: v19, - ender_items: v20, - abilities: v21, - entered_nether_position: v22, - root_vehicle: v23, - shoulder_entity_left: v24, - shoulder_entity_right: v25, - seen_credits: v26, - recipe_book: v27, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Player {} - - #[derive(Clone, Debug, PartialEq)] - pub struct Players { - pub players_: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for Players { - fn from(value: super::Players) -> Self { - Self { - players_: value - .players_ - .into_iter() - .map(|value| value.into()) - .collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Players { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.players_.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.players_._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { players_: v0 })) - } - } - - impl<'raw> ::bebop::Record<'raw> for Players {} -} diff --git a/src/datasets/minecraft_savedata/mod.rs b/src/datasets/minecraft_savedata/mod.rs index cd5a78a..9e680df 100644 --- a/src/datasets/minecraft_savedata/mod.rs +++ b/src/datasets/minecraft_savedata/mod.rs @@ -2,7 +2,7 @@ pub mod minecraft_savedata_capnp; #[cfg(feature = "flatbuffers")] #[path = "minecraft_savedata_generated.rs"] -#[allow(unused_imports)] +#[allow(unused_imports, clippy::all)] pub mod minecraft_savedata_fb; #[cfg(feature = "prost")] #[path = "prost.minecraft_savedata.rs"] @@ -32,7 +32,6 @@ use crate::bench_prost; use crate::{generate_vec, Generate}; #[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Enumeration))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -50,13 +49,12 @@ use crate::{generate_vec, Generate}; feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring), tag(u8))] @@ -88,10 +86,10 @@ impl Generate for GameType { } #[cfg(feature = "flatbuffers")] -impl Into for GameType { +impl From for fb::GameType { #[inline] - fn into(self) -> fb::GameType { - match self { + fn from(value: GameType) -> Self { + match value { GameType::Survival => fb::GameType::Survival, GameType::Creative => fb::GameType::Creative, GameType::Adventure => fb::GameType::Adventure, @@ -101,10 +99,10 @@ impl Into for GameType { } #[cfg(any(feature = "capnp", feature = "prost"))] -impl Into for GameType { +impl From for cp::GameType { #[inline] - fn into(self) -> cp::GameType { - match self { + fn from(value: GameType) -> Self { + match value { GameType::Survival => cp::GameType::Survival, GameType::Creative => cp::GameType::Creative, GameType::Adventure => cp::GameType::Adventure, @@ -114,10 +112,10 @@ impl Into for GameType { } #[cfg(feature = "prost")] -impl Into for GameType { +impl From for pb::GameType { #[inline] - fn into(self) -> pb::GameType { - match self { + fn from(value: GameType) -> Self { + match value { GameType::Survival => pb::GameType::Survival, GameType::Creative => pb::GameType::Creative, GameType::Adventure => pb::GameType::Adventure, @@ -138,21 +136,7 @@ impl From for GameType { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for GameType { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - match self { - GameType::Survival => GameTypeSurvivalPack.pack(offset, output), - GameType::Creative => GameTypeCreativePack.pack(offset, output), - GameType::Adventure => GameTypeAdventurePack.pack(offset, output), - GameType::Spectator => GameTypeSpectatorPack.pack(offset, output), - } - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -170,7 +154,7 @@ impl alkahest::Pack for GameType { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -248,11 +232,11 @@ impl bench_prost::Serialize for Item { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.count = self.count as i32; - result.slot = self.slot as u32; - result.id = self.id.clone(); - result + Self::Message { + count: self.count as i32, + slot: self.slot as u32, + id: self.id.clone(), + } } } @@ -267,29 +251,7 @@ impl From for Item { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct ItemSchema { - pub count: i8, - pub slot: u8, - pub id: alkahest::Bytes, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Item { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - ItemSchemaPack { - count: self.count, - slot: self.slot, - id: self.id.as_bytes(), - } - .pack(offset, output) - } -} - #[derive(Clone, Copy, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -307,13 +269,12 @@ impl alkahest::Pack for &'_ Item { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring))] @@ -343,17 +304,17 @@ impl Generate for Abilities { } #[cfg(feature = "flatbuffers")] -impl Into for Abilities { +impl From for fb::Abilities { #[inline] - fn into(self) -> fb::Abilities { - fb::Abilities::new( - self.walk_speed, - self.fly_speed, - self.may_fly, - self.flying, - self.invulnerable, - self.may_build, - self.instabuild, + fn from(value: Abilities) -> Self { + Self::new( + value.walk_speed, + value.fly_speed, + value.may_fly, + value.flying, + value.invulnerable, + value.may_build, + value.instabuild, ) } } @@ -381,15 +342,15 @@ impl bench_prost::Serialize for Abilities { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.walk_speed = self.walk_speed; - result.fly_speed = self.fly_speed; - result.may_fly = self.may_fly; - result.flying = self.flying; - result.invulnerable = self.invulnerable; - result.may_build = self.may_build; - result.instabuild = self.instabuild; - result + Self::Message { + walk_speed: self.walk_speed, + fly_speed: self.fly_speed, + may_fly: self.may_fly, + flying: self.flying, + invulnerable: self.invulnerable, + may_build: self.may_build, + instabuild: self.instabuild, + } } } @@ -408,25 +369,7 @@ impl From for Abilities { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for Abilities { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - AbilitiesPack { - walk_speed: self.walk_speed, - fly_speed: self.fly_speed, - may_fly: self.may_fly, - flying: self.flying, - invulnerable: self.invulnerable, - may_build: self.may_build, - instabuild: self.instabuild, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -444,7 +387,7 @@ impl alkahest::Pack for Abilities { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -597,50 +540,40 @@ impl bench_prost::Serialize for Entity { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.id = self.id.clone(); - result.pos = Some({ - let mut result = pb::Vector3d::default(); - result.x = self.pos.0; - result.y = self.pos.1; - result.z = self.pos.2; - result - }); - result.motion = Some({ - let mut result = pb::Vector3d::default(); - result.x = self.motion.0; - result.y = self.motion.1; - result.z = self.motion.2; - result - }); - result.rotation = Some({ - let mut result = pb::Vector2f::default(); - result.x = self.rotation.0; - result.y = self.rotation.1; - result - }); - result.fall_distance = self.fall_distance; - result.fire = self.fire as u32; - result.air = self.air as u32; - result.on_ground = self.on_ground; - result.no_gravity = self.no_gravity; - result.invulnerable = self.invulnerable; - result.portal_cooldown = self.portal_cooldown; - result.uuid = Some({ - let mut result = pb::Uuid::default(); - result.x0 = self.uuid[0]; - result.x1 = self.uuid[1]; - result.x2 = self.uuid[2]; - result.x3 = self.uuid[3]; - result - }); - if let Some(ref custom_name) = self.custom_name { - result.custom_name = Some(custom_name.clone()); + Self::Message { + id: self.id.clone(), + pos: Some(pb::Vector3d { + x: self.pos.0, + y: self.pos.1, + z: self.pos.2, + }), + motion: Some(pb::Vector3d { + x: self.motion.0, + y: self.motion.1, + z: self.motion.2, + }), + rotation: Some(pb::Vector2f { + x: self.rotation.0, + y: self.rotation.1, + }), + fall_distance: self.fall_distance, + fire: self.fire as u32, + air: self.air as u32, + on_ground: self.on_ground, + no_gravity: self.no_gravity, + invulnerable: self.invulnerable, + portal_cooldown: self.portal_cooldown, + uuid: Some(pb::Uuid { + x0: self.uuid[0], + x1: self.uuid[1], + x2: self.uuid[2], + x3: self.uuid[3], + }), + custom_name: self.custom_name.clone(), + custom_name_visible: self.custom_name_visible, + silent: self.silent, + glowing: self.glowing, } - result.custom_name_visible = self.custom_name_visible; - result.silent = self.silent; - result.glowing = self.glowing; - result } } @@ -689,55 +622,7 @@ impl From for Entity { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct EntitySchema { - pub id: alkahest::Bytes, - pub pos: (f64, f64, f64), - pub motion: (f64, f64, f64), - pub rotation: (f32, f32), - pub fall_distance: f32, - pub fire: u16, - pub air: u16, - pub on_ground: bool, - pub no_gravity: bool, - pub invulnerable: bool, - pub portal_cooldown: i32, - pub uuid: [u32; 4], - pub custom_name: Option, - pub custom_name_visible: bool, - pub silent: bool, - pub glowing: bool, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Entity { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - EntitySchemaPack { - id: self.id.as_bytes(), - pos: (self.pos.0, self.pos.1, self.pos.2), - motion: (self.motion.0, self.motion.1, self.motion.2), - rotation: (self.rotation.0, self.rotation.1), - fall_distance: self.fall_distance, - fire: self.fire, - air: self.air, - on_ground: self.on_ground, - no_gravity: self.no_gravity, - invulnerable: self.invulnerable, - portal_cooldown: self.portal_cooldown, - uuid: self.uuid, - custom_name: self.custom_name.as_ref().map(|s| s.as_bytes()), - custom_name_visible: self.custom_name_visible, - silent: self.silent, - glowing: self.glowing, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -755,7 +640,7 @@ impl alkahest::Pack for &'_ Entity { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -929,43 +814,7 @@ impl From for RecipeBook { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct RecipeBookSchema { - pub recipes: alkahest::Seq, - pub to_be_displayed: alkahest::Seq, - pub is_filtering_craftable: bool, - pub is_gui_open: bool, - pub is_furnace_filtering_craftable: bool, - pub is_furnace_gui_open: bool, - pub is_blasting_furnace_filtering_craftable: bool, - pub is_blasting_furnace_gui_open: bool, - pub is_smoker_filtering_craftable: bool, - pub is_smoker_gui_open: bool, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ RecipeBook { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - RecipeBookSchemaPack { - recipes: self.recipes.iter().map(|s| s.as_bytes()), - to_be_displayed: self.to_be_displayed.iter().map(|s| s.as_bytes()), - is_filtering_craftable: self.is_filtering_craftable, - is_gui_open: self.is_gui_open, - is_furnace_filtering_craftable: self.is_furnace_filtering_craftable, - is_furnace_gui_open: self.is_furnace_gui_open, - is_blasting_furnace_filtering_craftable: self.is_blasting_furnace_filtering_craftable, - is_blasting_furnace_gui_open: self.is_blasting_furnace_gui_open, - is_smoker_filtering_craftable: self.is_smoker_filtering_craftable, - is_smoker_gui_open: self.is_smoker_gui_open, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -983,7 +832,7 @@ impl alkahest::Pack for &'_ RecipeBook { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -1258,60 +1107,57 @@ impl bench_prost::Serialize for Player { type Message = pb::Player; fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.game_type = >::into(self.game_type) as i32; - result.previous_game_type = self.previous_game_type as i32; - result.score = self.score; - result.dimension = self.dimension.clone(); - result.selected_item_slot = self.selected_item_slot; - result.selected_item = Some(self.selected_item.serialize_pb()); - result.spawn_dimension = self.spawn_dimension.clone(); - result.spawn_x = self.spawn_x; - result.spawn_y = self.spawn_y; - result.spawn_z = self.spawn_z; - result.spawn_forced = self.spawn_forced; - result.sleep_timer = self.sleep_timer as u32; - result.food_exhaustion_level = self.food_exhaustion_level; - result.food_saturation_level = self.food_saturation_level; - result.food_tick_timer = self.food_tick_timer; - result.xp_level = self.xp_level as u32; - result.xp_p = self.xp_p; - result.xp_total = self.xp_total; - result.xp_seed = self.xp_seed; + let mut result = Self::Message { + game_type: pb::GameType::from(self.game_type) as i32, + previous_game_type: self.previous_game_type as i32, + score: self.score, + dimension: self.dimension.clone(), + selected_item_slot: self.selected_item_slot, + selected_item: Some(self.selected_item.serialize_pb()), + spawn_dimension: self.spawn_dimension.clone(), + spawn_x: self.spawn_x, + spawn_y: self.spawn_y, + spawn_z: self.spawn_z, + spawn_forced: self.spawn_forced, + sleep_timer: self.sleep_timer as u32, + food_exhaustion_level: self.food_exhaustion_level, + food_saturation_level: self.food_saturation_level, + food_tick_timer: self.food_tick_timer, + xp_level: self.xp_level, + xp_p: self.xp_p, + xp_total: self.xp_total, + xp_seed: self.xp_seed, + inventory: Default::default(), + ender_items: Default::default(), + abilities: Some(self.abilities.serialize_pb()), + entered_nether_position: self.entered_nether_position.map(|p| pb::Vector3d { + x: p.0, + y: p.1, + z: p.2, + }), + root_vehicle: self.root_vehicle.as_ref().map(|v| pb::Vehicle { + uuid: Some(pb::Uuid { + x0: v.0[0], + x1: v.0[1], + x2: v.0[2], + x3: v.0[3], + }), + entity: Some(v.1.serialize_pb()), + }), + shoulder_entity_left: self.shoulder_entity_left.as_ref().map(|e| e.serialize_pb()), + shoulder_entity_right: self + .shoulder_entity_right + .as_ref() + .map(|e| e.serialize_pb()), + seen_credits: self.seen_credits, + recipe_book: Some(self.recipe_book.serialize_pb()), + }; for item in self.inventory.iter() { result.inventory.push(item.serialize_pb()); } for item in self.ender_items.iter() { result.ender_items.push(item.serialize_pb()); } - result.abilities = Some(self.abilities.serialize_pb()); - result.entered_nether_position = self.entered_nether_position.map(|p| { - let mut result = pb::Vector3d::default(); - result.x = p.0; - result.y = p.1; - result.z = p.2; - result - }); - result.root_vehicle = self.root_vehicle.as_ref().map(|v| { - let mut result = pb::Vehicle::default(); - result.uuid = Some({ - let mut result = pb::Uuid::default(); - result.x0 = v.0[0]; - result.x1 = v.0[1]; - result.x2 = v.0[2]; - result.x3 = v.0[3]; - result - }); - result.entity = Some(v.1.serialize_pb()); - result - }); - result.shoulder_entity_left = self.shoulder_entity_left.as_ref().map(|e| e.serialize_pb()); - result.shoulder_entity_right = self - .shoulder_entity_right - .as_ref() - .map(|e| e.serialize_pb()); - result.seen_credits = self.seen_credits; - result.recipe_book = Some(self.recipe_book.serialize_pb()); result } } @@ -1356,85 +1202,7 @@ impl From for Player { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct PlayerSchema { - pub game_type: GameType, - pub previous_game_type: GameType, - pub score: i64, - pub dimension: alkahest::Bytes, - pub selected_item_slot: u32, - pub selected_item: ItemSchema, - pub spawn_dimension: Option, - pub spawn_x: i64, - pub spawn_y: i64, - pub spawn_z: i64, - pub spawn_forced: Option, - pub sleep_timer: u16, - pub food_exhaustion_level: f32, - pub food_saturation_level: f32, - pub food_tick_timer: u32, - pub xp_level: u32, - pub xp_p: f32, - pub xp_total: i32, - pub xp_seed: i32, - pub inventory: alkahest::Seq, - pub ender_items: alkahest::Seq, - pub abilities: Abilities, - pub entered_nether_position: Option<(f64, f64, f64)>, - pub root_vehicle: Option<([u32; 4], EntitySchema)>, - pub shoulder_entity_left: Option, - pub shoulder_entity_right: Option, - pub seen_credits: bool, - pub recipe_book: RecipeBookSchema, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Player { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - PlayerSchemaPack { - game_type: self.game_type, - previous_game_type: self.previous_game_type, - score: self.score, - dimension: self.dimension.as_bytes(), - selected_item_slot: self.selected_item_slot, - selected_item: &self.selected_item, - spawn_dimension: self.spawn_dimension.as_ref().map(|s| s.as_bytes()), - spawn_x: self.spawn_x, - spawn_y: self.spawn_y, - spawn_z: self.spawn_z, - spawn_forced: self.spawn_forced, - sleep_timer: self.sleep_timer, - food_exhaustion_level: self.food_exhaustion_level, - food_saturation_level: self.food_saturation_level, - food_tick_timer: self.food_tick_timer, - xp_level: self.xp_level, - xp_p: self.xp_p, - xp_total: self.xp_total, - xp_seed: self.xp_seed, - inventory: self.inventory.iter(), - ender_items: self.ender_items.iter(), - abilities: self.abilities, - entered_nether_position: self - .entered_nether_position - .as_ref() - .map(|p| (p.0, p.1, p.2)), - root_vehicle: self - .root_vehicle - .as_ref() - .map(|(array, entity)| (array, entity)), - shoulder_entity_left: self.shoulder_entity_left.as_ref(), - shoulder_entity_right: self.shoulder_entity_right.as_ref(), - seen_credits: self.seen_credits, - recipe_book: &self.recipe_book, - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -1452,7 +1220,7 @@ impl alkahest::Pack for &'_ Player { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -1523,19 +1291,3 @@ impl From for Players { } } } - -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct PlayersSchema { - pub players: alkahest::Seq, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Players { - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - PlayersSchemaPack { - players: self.players.iter(), - } - .pack(offset, output) - } -} diff --git a/src/datasets/mk48/mk48.bop b/src/datasets/mk48/mk48.bop deleted file mode 100644 index 22f8d1c..0000000 --- a/src/datasets/mk48/mk48.bop +++ /dev/null @@ -1,62 +0,0 @@ -enum EntityType { - ARLEIGH_BURKE = 1; - BISMARCK = 2; - CLEMENCEAU = 3; - FLETCHER = 4; - G5 = 5; - IOWA = 6; - KOLKATA = 7; - OSA = 8; - YASEN = 9; - ZUBR = 10; -} - -struct Vector2F { - float32 x; - float32 y; -} - -struct Transform { - int16 altitude; - uint16 angle; - Vector2F position; - int16 velocity; -} - -struct Guidance { - uint16 angle; - bool submerge; - int16 velocity; -} - -struct Contact { - byte damage; - uint32 entity_id; - EntityType entity_type; - Guidance guidance; - uint32 player_id; - bool[] reloads; - Transform transform; - uint32[] turret_angles; -} - -struct ChunkId { - int32 x; - int32 y; -} - -struct TerrainUpdate { - ChunkId chunk_id; - byte[] data; -} - -struct Update { - Contact[] contacts; - uint32 score; - float32 world_radius; - TerrainUpdate[] terrain_updates; -} - -struct Updates { - Update[] updates_; -} diff --git a/src/datasets/mk48/mk48_bebop.rs b/src/datasets/mk48/mk48_bebop.rs deleted file mode 100644 index ca240e9..0000000 --- a/src/datasets/mk48/mk48_bebop.rs +++ /dev/null @@ -1,834 +0,0 @@ -// -// This code was generated by a tool. -// -// -// bebopc version: -// 2.8.5 -// -// -// bebopc source: -// https://github.com/RainwayApp/bebop -// -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// - -#![allow(warnings)] - -use bebop::FixedSized as _; -use core::convert::TryInto as _; -use std::io::Write as _; - -#[repr(u32)] -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum EntityType { - ArleighBurke = 1, - Bismarck = 2, - Clemenceau = 3, - Fletcher = 4, - G5 = 5, - Iowa = 6, - Kolkata = 7, - Osa = 8, - Yasen = 9, - Zubr = 10, -} - -impl ::core::convert::TryFrom for EntityType { - type Error = ::bebop::DeserializeError; - - fn try_from(value: u32) -> ::bebop::DeResult { - match value { - 1 => Ok(EntityType::ArleighBurke), - 2 => Ok(EntityType::Bismarck), - 3 => Ok(EntityType::Clemenceau), - 4 => Ok(EntityType::Fletcher), - 5 => Ok(EntityType::G5), - 6 => Ok(EntityType::Iowa), - 7 => Ok(EntityType::Kolkata), - 8 => Ok(EntityType::Osa), - 9 => Ok(EntityType::Yasen), - 10 => Ok(EntityType::Zubr), - d => Err(::bebop::DeserializeError::InvalidEnumDiscriminator( - d.into(), - )), - } - } -} - -impl ::core::convert::From for u32 { - fn from(value: EntityType) -> Self { - match value { - EntityType::ArleighBurke => 1, - EntityType::Bismarck => 2, - EntityType::Clemenceau => 3, - EntityType::Fletcher => 4, - EntityType::G5 => 5, - EntityType::Iowa => 6, - EntityType::Kolkata => 7, - EntityType::Osa => 8, - EntityType::Yasen => 9, - EntityType::Zubr => 10, - } - } -} - -impl ::bebop::SubRecord<'_> for EntityType { - const MIN_SERIALIZED_SIZE: usize = ::std::mem::size_of::(); - const EXACT_SERIALIZED_SIZE: Option = Some(::std::mem::size_of::()); - - #[inline] - fn serialized_size(&self) -> usize { - ::std::mem::size_of::() - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - u32::from(zelf)._serialize_chained(dest) - }); - - #[inline] - fn _deserialize_chained(raw: &[u8]) -> ::bebop::DeResult<(usize, Self)> { - let (n, v) = u32::_deserialize_chained(raw)?; - Ok((n, v.try_into()?)) - } -} - -impl ::bebop::FixedSized for EntityType { - const SERIALIZED_SIZE: usize = ::std::mem::size_of::(); -} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Vector2F { - pub x: f32, - pub y: f32, -} - -impl ::bebop::FixedSized for Vector2F {} - -impl<'raw> ::bebop::SubRecord<'raw> for Vector2F { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.y)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { x: v0, y: v1 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for Vector2F {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Transform { - pub altitude: i16, - pub angle: u16, - pub position: Vector2F, - pub velocity: i16, -} - -impl ::bebop::FixedSized for Transform {} - -impl<'raw> ::bebop::SubRecord<'raw> for Transform { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.altitude)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.angle)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.position)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.velocity)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - altitude: v0, - angle: v1, - position: v2, - velocity: v3, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Transform {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct Guidance { - pub angle: u16, - pub submerge: bool, - pub velocity: i16, -} - -impl ::bebop::FixedSized for Guidance {} - -impl<'raw> ::bebop::SubRecord<'raw> for Guidance { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.angle)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.submerge)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.velocity)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - angle: v0, - submerge: v1, - velocity: v2, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Guidance {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Contact<'raw> { - pub damage: u8, - pub entity_id: u32, - pub entity_type: EntityType, - pub guidance: Guidance, - pub player_id: u32, - pub reloads: ::bebop::SliceWrapper<'raw, bool>, - pub transform: Transform, - pub turret_angles: ::bebop::SliceWrapper<'raw, u32>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Contact<'raw> { - const MIN_SERIALIZED_SIZE: usize = ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::bebop::SliceWrapper<'raw, bool>>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::bebop::SliceWrapper<'raw, u32>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.damage.serialized_size() - + self.entity_id.serialized_size() - + self.entity_type.serialized_size() - + self.guidance.serialized_size() - + self.player_id.serialized_size() - + self.reloads.serialized_size() - + self.transform.serialized_size() - + self.turret_angles.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.damage._serialize_chained(dest)? + - zelf.entity_id._serialize_chained(dest)? + - zelf.entity_type._serialize_chained(dest)? + - zelf.guidance._serialize_chained(dest)? + - zelf.player_id._serialize_chained(dest)? + - zelf.reloads._serialize_chained(dest)? + - zelf.transform._serialize_chained(dest)? + - zelf.turret_angles._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - damage: v0, - entity_id: v1, - entity_type: v2, - guidance: v3, - player_id: v4, - reloads: v5, - transform: v6, - turret_angles: v7, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Contact<'raw> {} - -#[derive(Clone, Debug, PartialEq, Copy)] -#[repr(packed)] -pub struct ChunkId { - pub x: i32, - pub y: i32, -} - -impl ::bebop::FixedSized for ChunkId {} - -impl<'raw> ::bebop::SubRecord<'raw> for ChunkId { - const MIN_SERIALIZED_SIZE: usize = Self::SERIALIZED_SIZE; - const EXACT_SERIALIZED_SIZE: Option = Some(Self::SERIALIZED_SIZE); - - #[inline] - fn serialized_size(&self) -> usize { - Self::SERIALIZED_SIZE - } - - ::bebop::define_serialize_chained!(*Self => |zelf, dest| { - Ok( - ::bebop::packed_read!(zelf.x)._serialize_chained(dest)? + - ::bebop::packed_read!(zelf.y)._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { x: v0, y: v1 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for ChunkId {} - -#[derive(Clone, Debug, PartialEq)] -pub struct TerrainUpdate<'raw> { - pub chunk_id: ChunkId, - pub data: ::bebop::SliceWrapper<'raw, u8>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for TerrainUpdate<'raw> { - const MIN_SERIALIZED_SIZE: usize = - ::MIN_SERIALIZED_SIZE + <::bebop::SliceWrapper<'raw, u8>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.chunk_id.serialized_size() + self.data.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.chunk_id._serialize_chained(dest)? + - zelf.data._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - chunk_id: v0, - data: v1, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for TerrainUpdate<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Update<'raw> { - pub contacts: ::std::vec::Vec>, - pub score: u32, - pub world_radius: f32, - pub terrain_updates: ::std::vec::Vec>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Update<'raw> { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.contacts.serialized_size() - + self.score.serialized_size() - + self.world_radius.serialized_size() - + self.terrain_updates.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.contacts._serialize_chained(dest)? + - zelf.score._serialize_chained(dest)? + - zelf.world_radius._serialize_chained(dest)? + - zelf.terrain_updates._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - contacts: v0, - score: v1, - world_radius: v2, - terrain_updates: v3, - }, - )) - } -} - -impl<'raw> ::bebop::Record<'raw> for Update<'raw> {} - -#[derive(Clone, Debug, PartialEq)] -pub struct Updates<'raw> { - pub updates_: ::std::vec::Vec>, -} - -impl<'raw> ::bebop::SubRecord<'raw> for Updates<'raw> { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.updates_.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.updates_._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { updates_: v0 })) - } -} - -impl<'raw> ::bebop::Record<'raw> for Updates<'raw> {} - -#[cfg(feature = "bebop-owned-all")] -pub mod owned { - #![allow(warnings)] - - use bebop::FixedSized as _; - use core::convert::TryInto as _; - use std::io::Write as _; - - pub use super::EntityType; - - pub use super::Vector2F; - - pub use super::Transform; - - pub use super::Guidance; - - #[derive(Clone, Debug, PartialEq)] - pub struct Contact { - pub damage: u8, - pub entity_id: u32, - pub entity_type: EntityType, - pub guidance: Guidance, - pub player_id: u32, - pub reloads: ::std::vec::Vec, - pub transform: Transform, - pub turret_angles: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for Contact { - fn from(value: super::Contact) -> Self { - Self { - damage: value.damage, - entity_id: value.entity_id, - entity_type: value.entity_type, - guidance: value.guidance, - player_id: value.player_id, - reloads: value.reloads.iter().map(|value| value).collect(), - transform: value.transform, - turret_angles: value.turret_angles.iter().map(|value| value).collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Contact { - const MIN_SERIALIZED_SIZE: usize = ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.damage.serialized_size() - + self.entity_id.serialized_size() - + self.entity_type.serialized_size() - + self.guidance.serialized_size() - + self.player_id.serialized_size() - + self.reloads.serialized_size() - + self.transform.serialized_size() - + self.turret_angles.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.damage._serialize_chained(dest)? + - zelf.entity_id._serialize_chained(dest)? + - zelf.entity_type._serialize_chained(dest)? + - zelf.guidance._serialize_chained(dest)? + - zelf.player_id._serialize_chained(dest)? + - zelf.reloads._serialize_chained(dest)? + - zelf.transform._serialize_chained(dest)? + - zelf.turret_angles._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v4) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v5) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v6) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v7) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - damage: v0, - entity_id: v1, - entity_type: v2, - guidance: v3, - player_id: v4, - reloads: v5, - transform: v6, - turret_angles: v7, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Contact {} - - pub use super::ChunkId; - - #[derive(Clone, Debug, PartialEq)] - pub struct TerrainUpdate { - pub chunk_id: ChunkId, - pub data: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for TerrainUpdate { - fn from(value: super::TerrainUpdate) -> Self { - Self { - chunk_id: value.chunk_id, - data: value.data.iter().map(|value| value).collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for TerrainUpdate { - const MIN_SERIALIZED_SIZE: usize = - ::MIN_SERIALIZED_SIZE + <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.chunk_id.serialized_size() + self.data.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.chunk_id._serialize_chained(dest)? + - zelf.data._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - chunk_id: v0, - data: v1, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for TerrainUpdate {} - - #[derive(Clone, Debug, PartialEq)] - pub struct Update { - pub contacts: ::std::vec::Vec, - pub score: u32, - pub world_radius: f32, - pub terrain_updates: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for Update { - fn from(value: super::Update) -> Self { - Self { - contacts: value - .contacts - .into_iter() - .map(|value| value.into()) - .collect(), - score: value.score, - world_radius: value.world_radius, - terrain_updates: value - .terrain_updates - .into_iter() - .map(|value| value.into()) - .collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Update { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + ::MIN_SERIALIZED_SIZE - + <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.contacts.serialized_size() - + self.score.serialized_size() - + self.world_radius.serialized_size() - + self.terrain_updates.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.contacts._serialize_chained(dest)? + - zelf.score._serialize_chained(dest)? + - zelf.world_radius._serialize_chained(dest)? + - zelf.terrain_updates._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v1) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v2) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - let (read, v3) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok(( - i, - Self { - contacts: v0, - score: v1, - world_radius: v2, - terrain_updates: v3, - }, - )) - } - } - - impl<'raw> ::bebop::Record<'raw> for Update {} - - #[derive(Clone, Debug, PartialEq)] - pub struct Updates { - pub updates_: ::std::vec::Vec, - } - - impl<'raw> ::core::convert::From> for Updates { - fn from(value: super::Updates) -> Self { - Self { - updates_: value - .updates_ - .into_iter() - .map(|value| value.into()) - .collect(), - } - } - } - - impl<'raw> ::bebop::SubRecord<'raw> for Updates { - const MIN_SERIALIZED_SIZE: usize = <::std::vec::Vec>::MIN_SERIALIZED_SIZE; - - #[inline] - fn serialized_size(&self) -> usize { - self.updates_.serialized_size() - } - - ::bebop::define_serialize_chained!(Self => |zelf, dest| { - Ok( - zelf.updates_._serialize_chained(dest)? - ) - }); - - fn _deserialize_chained(raw: &'raw [u8]) -> ::bebop::DeResult<(usize, Self)> { - let mut i = 0; - if raw.len() - i < Self::MIN_SERIALIZED_SIZE { - let missing = Self::MIN_SERIALIZED_SIZE - (raw.len() - i); - return Err(::bebop::DeserializeError::MoreDataExpected(missing)); - } - - let (read, v0) = ::bebop::SubRecord::_deserialize_chained(&raw[i..])?; - i += read; - - Ok((i, Self { updates_: v0 })) - } - } - - impl<'raw> ::bebop::Record<'raw> for Updates {} -} diff --git a/src/datasets/mk48/mod.rs b/src/datasets/mk48/mod.rs index 8cca55c..0a8a0fa 100644 --- a/src/datasets/mk48/mod.rs +++ b/src/datasets/mk48/mod.rs @@ -1,10 +1,8 @@ -#[cfg(feature = "bebop")] -pub mod mk48_bebop; #[cfg(any(feature = "capnp", feature = "prost"))] pub mod mk48_capnp; #[cfg(feature = "flatbuffers")] #[path = "mk48_generated.rs"] -#[allow(unused_imports)] +#[allow(unused_imports, clippy::all)] pub mod mk48_fb; #[cfg(feature = "prost")] #[path = "prost.mk48.rs"] @@ -33,7 +31,6 @@ use crate::bench_prost; use crate::{generate_vec, Generate}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Enumeration))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -51,13 +48,12 @@ use crate::{generate_vec, Generate}; feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring), tag(u8))] @@ -164,10 +160,10 @@ impl Generate for EntityType { } #[cfg(feature = "flatbuffers")] -impl Into for EntityType { +impl From for fb::EntityType { #[inline] - fn into(self) -> fb::EntityType { - match self { + fn from(value: EntityType) -> Self { + match value { EntityType::ArleighBurke => fb::EntityType::ArleighBurke, EntityType::Bismarck => fb::EntityType::Bismarck, EntityType::Clemenceau => fb::EntityType::Clemenceau, @@ -183,10 +179,10 @@ impl Into for EntityType { } #[cfg(any(feature = "capnp", feature = "prost"))] -impl Into for EntityType { +impl From for cp::EntityType { #[inline] - fn into(self) -> cp::EntityType { - match self { + fn from(value: EntityType) -> Self { + match value { EntityType::ArleighBurke => cp::EntityType::ArleighBurke, EntityType::Bismarck => cp::EntityType::Bismarck, EntityType::Clemenceau => cp::EntityType::Clemenceau, @@ -202,10 +198,10 @@ impl Into for EntityType { } #[cfg(feature = "prost")] -impl Into for EntityType { +impl From for pb::EntityType { #[inline] - fn into(self) -> pb::EntityType { - match self { + fn from(value: EntityType) -> Self { + match value { EntityType::ArleighBurke => pb::EntityType::ArleighBurke, EntityType::Bismarck => pb::EntityType::Bismarck, EntityType::Clemenceau => pb::EntityType::Clemenceau, @@ -238,26 +234,6 @@ impl From for EntityType { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for EntityType { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - use EntityType::*; - match self { - ArleighBurke => EntityTypeArleighBurkePack.pack(offset, output), - Bismarck => EntityTypeBismarckPack.pack(offset, output), - Clemenceau => EntityTypeClemenceauPack.pack(offset, output), - Fletcher => EntityTypeFletcherPack.pack(offset, output), - G5 => EntityTypeG5Pack.pack(offset, output), - Iowa => EntityTypeIowaPack.pack(offset, output), - Kolkata => EntityTypeKolkataPack.pack(offset, output), - Osa => EntityTypeOsaPack.pack(offset, output), - Yasen => EntityTypeYasenPack.pack(offset, output), - Zubr => EntityTypeZubrPack.pack(offset, output), - } - } -} - fn generate_submerge(rng: &mut impl Rng, entity_type: EntityType) -> bool { entity_type.is_sub() && rng.gen_bool(0.9) } @@ -284,7 +260,6 @@ fn generate_velocity(rng: &mut impl Rng) -> i16 { } #[derive(Copy, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -302,13 +277,12 @@ fn generate_velocity(rng: &mut impl Rng) -> i16 { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring))] @@ -334,13 +308,13 @@ impl Transform { } #[cfg(feature = "flatbuffers")] -impl Into for Transform { - fn into(self) -> fb::Transform { +impl From for fb::Transform { + fn from(value: Transform) -> Self { fb::Transform::new( - self.altitude, - self.angle, - &fb::Vector2f::new(self.position.0, self.position.1), - self.velocity, + value.altitude, + value.angle, + &fb::Vector2f::new(value.position.0, value.position.1), + value.velocity, ) } } @@ -367,17 +341,15 @@ impl bench_prost::Serialize for Transform { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.altitude = self.altitude.into(); - result.angle = self.angle.into(); - result.position = Some({ - let mut result = pb::Vector2f::default(); - result.x = self.position.0; - result.y = self.position.1; - result - }); - result.velocity = self.velocity.into(); - result + Self::Message { + altitude: self.altitude.into(), + angle: self.angle.into(), + position: Some(pb::Vector2f { + x: self.position.0, + y: self.position.1, + }), + velocity: self.velocity.into(), + } } } @@ -400,22 +372,7 @@ impl From for Transform { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for Transform { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - TransformPack { - altitude: self.altitude, - angle: self.angle, - position: self.position, - velocity: self.velocity, - } - .pack(offset, output) - } -} - #[derive(Copy, Clone, Debug, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -433,13 +390,12 @@ impl alkahest::Pack for Transform { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) )] #[cfg_attr(feature = "speedy", derive(speedy::Readable, speedy::Writable))] -#[cfg_attr(feature = "alkahest", derive(alkahest::Schema))] #[cfg_attr(feature = "savefile", derive(savefile_derive::Savefile))] #[cfg_attr(feature = "nanoserde", derive(nanoserde::SerBin, nanoserde::DeBin))] #[cfg_attr(feature = "wiring", derive(Wiring, Unwiring))] @@ -461,10 +417,10 @@ impl Guidance { } #[cfg(feature = "flatbuffers")] -impl Into for Guidance { +impl From for fb::Guidance { #[inline] - fn into(self) -> fb::Guidance { - fb::Guidance::new(self.angle, self.submerge, self.velocity) + fn from(value: Guidance) -> Self { + Self::new(value.angle, value.submerge, value.velocity) } } @@ -477,7 +433,7 @@ impl<'a> bench_capnp::Serialize<'a> for Guidance { fn serialize_capnp(&self, builder: &mut Self::Builder) { builder.set_angle(self.angle); builder.set_submerge(self.submerge); - builder.set_velocity(self.velocity.into()); + builder.set_velocity(self.velocity); } } @@ -487,11 +443,11 @@ impl bench_prost::Serialize for Guidance { #[inline] fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.angle = self.angle as u32; - result.submerge = self.submerge; - result.velocity = self.velocity as i32; - result + Self::Message { + angle: self.angle as u32, + submerge: self.submerge, + velocity: self.velocity as i32, + } } } @@ -506,21 +462,7 @@ impl From for Guidance { } } -#[cfg(feature = "alkahest")] -impl alkahest::Pack for Guidance { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - GuidancePack { - angle: self.angle, - submerge: self.submerge, - velocity: self.velocity, - } - .pack(offset, output) - } -} - #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -538,7 +480,7 @@ impl alkahest::Pack for Guidance { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -677,18 +619,21 @@ impl bench_prost::Serialize for Contact { type Message = pb::Contact; fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.damage = self.damage as u32; - result.entity_id = self.entity_id; - result.entity_type = self - .entity_type - .map(|entity_type| >::into(entity_type) as i32); - result.guidance = Some(self.guidance.serialize_pb()); - result.player_id = self.player_id.map(Into::into); + let mut result = Self::Message { + damage: self.damage as u32, + entity_id: self.entity_id, + entity_type: self + .entity_type + .map(|entity_type| cp::EntityType::from(entity_type) as i32), + guidance: Some(self.guidance.serialize_pb()), + player_id: self.player_id.map(Into::into), + reloads: Default::default(), + transform: Some(self.transform.serialize_pb()), + turret_angles: Default::default(), + }; for reload in self.reloads.iter().cloned() { result.reloads.push(reload); } - result.transform = Some(self.transform.serialize_pb()); for turret_angle in self.turret_angles.iter().cloned() { result.turret_angles.push(turret_angle as u32); } @@ -718,39 +663,7 @@ impl From for Contact { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct ContactSchema { - pub damage: u8, - pub entity_id: u32, - pub entity_type: Option, - pub guidance: Guidance, - pub player_id: Option, - pub reloads: alkahest::Seq, - pub transform: Transform, - pub turret_angles: alkahest::Seq, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Contact { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - ContactSchemaPack { - damage: self.damage, - entity_id: self.entity_id, - entity_type: self.entity_type, - guidance: self.guidance, - player_id: self.player_id, - reloads: self.reloads.iter(), - transform: self.transform, - turret_angles: self.turret_angles.iter(), - } - .pack(offset, output) - } -} - #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -768,7 +681,7 @@ impl alkahest::Pack for &'_ Contact { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -838,12 +751,12 @@ impl bench_prost::Serialize for TerrainUpdate { type Message = pb::TerrainUpdate; fn serialize_pb(&self) -> Self::Message { - let mut result = Self::Message::default(); - result.chunk_id = { - let mut result = pb::ChunkId::default(); - result.x = self.chunk_id.0 as i32; - result.y = self.chunk_id.1 as i32; - Some(result) + let mut result = Self::Message { + chunk_id: Some(pb::ChunkId { + x: self.chunk_id.0 as i32, + y: self.chunk_id.1 as i32, + }), + data: Default::default(), }; for datum in self.data.iter().cloned() { result.data.push(datum); @@ -869,31 +782,7 @@ impl From for TerrainUpdate { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct TerrainUpdateSchema { - pub chunk_id: (i8, i8), - pub data: alkahest::Bytes, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ TerrainUpdate { - #[inline] - fn pack( - self, - offset: usize, - output: &mut [u8], - ) -> (alkahest::Packed, usize) { - TerrainUpdateSchemaPack { - chunk_id: self.chunk_id, - data: self.data.iter(), - } - .pack(offset, output) - } -} - #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -911,7 +800,7 @@ impl alkahest::Pack for &'_ TerrainUpdate { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -1030,31 +919,7 @@ impl From for Update { } } -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct UpdateSchema { - pub contacts: alkahest::Seq, - pub score: u32, - pub world_radius: f32, - pub terrain_updates: alkahest::Seq, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Update { - #[inline] - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - UpdateSchemaPack { - contacts: self.contacts.iter(), - score: self.score, - world_radius: self.world_radius, - terrain_updates: self.terrain_updates.iter(), - } - .pack(offset, output) - } -} - #[derive(Clone, PartialEq)] -#[cfg_attr(feature = "abomonation", derive(abomonation_derive::Abomonation))] #[cfg_attr(feature = "bilrost", derive(bilrost::Message))] #[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))] #[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] @@ -1072,7 +937,7 @@ impl alkahest::Pack for &'_ Update { feature = "scale", derive(parity_scale_codec_derive::Encode, parity_scale_codec_derive::Decode) )] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(serde::Serialize, serde::Deserialize)] #[cfg_attr( feature = "simd-json", derive(simd_json_derive::Serialize, simd_json_derive::Deserialize) @@ -1143,19 +1008,3 @@ impl From for Updates { } } } - -#[cfg(feature = "alkahest")] -#[derive(alkahest::Schema)] -pub struct UpdatesSchema { - pub updates: alkahest::Seq, -} - -#[cfg(feature = "alkahest")] -impl alkahest::Pack for &'_ Updates { - fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed, usize) { - UpdatesSchemaPack { - updates: self.updates.iter(), - } - .pack(offset, output) - } -} diff --git a/src/lib.rs b/src/lib.rs index 83579a0..3d6b7c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ -#[cfg(feature = "abomonation")] -pub mod bench_abomonation; -#[cfg(feature = "alkahest")] -pub mod bench_alkahest; +// wiring causes this clippy lint everywhere +#![cfg_attr(feature = "wiring", allow(clippy::manual_async_fn))] + #[cfg(feature = "bilrost")] pub mod bench_bilrost; #[cfg(feature = "bincode")] @@ -12,8 +11,6 @@ pub mod bench_bincode1; pub mod bench_bitcode; #[cfg(feature = "borsh")] pub mod bench_borsh; -#[cfg(feature = "bson")] -pub mod bench_bson; #[cfg(feature = "capnp")] pub mod bench_capnp; #[cfg(feature = "cbor4ii")] @@ -120,33 +117,19 @@ macro_rules! impl_tuple { impl_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,); -macro_rules! impl_array { - () => {}; - ($len:literal, $($rest:literal,)*) => { - impl Generate for [T; $len] { - fn generate(rng: &mut R) -> Self { - let mut result = mem::MaybeUninit::::uninit(); - let result_ptr = result.as_mut_ptr().cast::(); - for i in 0..$len { - unsafe { - result_ptr.add(i).write(T::generate(rng)); - } - } - unsafe { - result.assume_init() - } +impl Generate for [T; N] { + fn generate(rng: &mut R) -> Self { + let mut result = mem::MaybeUninit::::uninit(); + let result_ptr = result.as_mut_ptr().cast::(); + for i in 0..N { + unsafe { + result_ptr.add(i).write(T::generate(rng)); } } - - impl_array!($($rest,)*); + unsafe { result.assume_init() } } } -impl_array!( - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, - 7, 6, 5, 4, 3, 2, 1, 0, -); - impl Generate for Option { fn generate(rng: &mut R) -> Self { if rng.gen_bool(0.5) { diff --git a/tools/formatter/src/main.rs b/tools/formatter/src/main.rs index d78eaf0..45ecfaa 100644 --- a/tools/formatter/src/main.rs +++ b/tools/formatter/src/main.rs @@ -213,7 +213,7 @@ fn format( ```", results.rustc_info.trim_end(), ); - for cpu_info in &results.cpu_info { + if let Some(cpu_info) = &results.cpu_info { write!( &mut runtime_info, "\n\