diff --git a/Cargo.lock b/Cargo.lock index 6d743b820..94b691da0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,6 +319,23 @@ dependencies = [ "serde_core", ] +[[package]] +name = "buffa" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92f2f5df67a9d5ccfc65237bfc954c56328aee40a04a9b92381ecba370be246" +dependencies = [ + "bytes", + "foldhash 0.1.5", + "hashbrown 0.15.5", + "once_cell", + "rustversion", + "serde", + "serde_json", + "smoothutf8", + "thiserror 2.0.19", +] + [[package]] name = "bumpalo" version = "3.20.3" @@ -1079,6 +1096,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foldhash" version = "0.2.0" @@ -1337,6 +1360,15 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + [[package]] name = "hashbrown" version = "0.16.1" @@ -1351,7 +1383,7 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.2.0", ] [[package]] @@ -1780,15 +1812,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.18" @@ -2539,29 +2562,6 @@ dependencies = [ "unarray", ] -[[package]] -name = "prost" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-derive" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" -dependencies = [ - "anyhow", - "itertools 0.14.0", - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -3272,6 +3272,12 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "simlin" version = "0.1.0" @@ -3279,7 +3285,6 @@ dependencies = [ "anyhow", "checked", "mimalloc", - "prost", "serde", "serde_json", "simlin-engine", @@ -3303,6 +3308,7 @@ name = "simlin-engine" version = "0.1.0" dependencies = [ "base64", + "buffa", "calamine", "checked", "criterion", @@ -3313,7 +3319,6 @@ dependencies = [ "jsonschema", "mimalloc", "proptest", - "prost", "quick-xml 0.41.0", "rand 0.9.5", "rayon", @@ -3448,6 +3453,15 @@ dependencies = [ "serde", ] +[[package]] +name = "smoothutf8" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4ec95892483d6d94284caccfddb9b77111a4dcac33ed25d624248def0fa5f1" +dependencies = [ + "simdutf8", +] + [[package]] name = "socket2" version = "0.6.5" diff --git a/scripts/gen-rust-protobufs.sh b/scripts/gen-rust-protobufs.sh index 33ff3e980..faf1b7f7e 100755 --- a/scripts/gen-rust-protobufs.sh +++ b/scripts/gen-rust-protobufs.sh @@ -16,57 +16,91 @@ OUTPUT_FILE="$ROOT_DIR/src/simlin-engine/src/project_io.gen.rs" TOOLCHAIN=$(grep '^channel' "$ROOT_DIR/rust-toolchain.toml" | cut -d '"' -f 2) export RUSTUP_TOOLCHAIN="$TOOLCHAIN" +# The generator must be exactly the version of the `buffa` runtime the +# workspace links: generated code calls runtime internals (`__private` helpers, +# trait methods) that are not covered by semver, so a newer buffa-build than +# the locked runtime can emit code the runtime cannot compile. Cargo.lock is +# the source of truth for that runtime version. +BUFFA_VERSION=$(awk '/^name = "buffa"$/ { getline; gsub(/"/, "", $3); print $3; exit }' "$ROOT_DIR/Cargo.lock") +if [ -z "$BUFFA_VERSION" ]; then + echo "error: no buffa package in $ROOT_DIR/Cargo.lock" >&2 + exit 1 +fi + # Compute SHA256 hash of the proto file PROTO_HASH=$(sha256sum "$PROTO_FILE" | cut -d ' ' -f 1) -# Create a temporary directory for the prost-build project +# Create a temporary directory for the buffa-build project TEMP_DIR=$(mktemp -d) trap "rm -rf $TEMP_DIR" EXIT -# Create a minimal Cargo project that uses prost-build -mkdir -p "$TEMP_DIR/src" -cat > "$TEMP_DIR/Cargo.toml" << 'EOF' +# Create a minimal Cargo project that uses buffa-build +mkdir -p "$TEMP_DIR/src" "$TEMP_DIR/out" +cat > "$TEMP_DIR/Cargo.toml" << EOF [package] name = "proto-gen" version = "0.1.0" edition = "2024" [build-dependencies] -prost-build = "0.14" +buffa-build = "=$BUFFA_VERSION" EOF cat > "$TEMP_DIR/src/lib.rs" << 'EOF' // placeholder EOF +# Codegen options, each chosen for how the engine uses these types (as a +# serialization format converted to and from `datamodel` in serde.rs): +# - no views: nothing decodes zero-copy, and views roughly double the output. +# - one file per package: a single checked-in file carrying the hash header +# below, with the oneof enums re-exported where the message modules name them +# (`variable::V`, `view_element::Element`, ...). +# - unknown fields dropped: the engine never re-emits a message it decoded, so +# preserving them buys nothing, and without the hidden bookkeeping field the +# messages stay constructible with plain struct literals. +# - no `with_*` setters: unused. +# - idiomatic field names: the proto has camelCase fields (`viewBox`), which +# read as snake_case Rust fields (`view_box`) without renaming anything on +# the wire. +# - oneof variants stored inline: no oneof here is recursive, so the default +# per-variant `Box` would only add an allocation per variant. cat > "$TEMP_DIR/build.rs" << EOF fn main() { - let mut config = prost_build::Config::new(); - config.protoc_arg("--experimental_allow_proto3_optional"); - config.out_dir("$TEMP_DIR"); - config.compile_protos(&["$PROTO_FILE"], &["$(dirname "$PROTO_FILE")"]).unwrap(); + buffa_build::Config::new() + .files(&["$PROTO_FILE"]) + .includes(&["$(dirname "$PROTO_FILE")"]) + .out_dir("$TEMP_DIR/out") + .generate_views(false) + .file_per_package(true) + .preserve_unknown_fields(false) + .generate_with_setters(false) + .idiomatic_field_names(true) + .unbox_oneof() + .compile() + .unwrap(); } EOF -# Run the build to generate the protobuf code. prost-build shells out to +# Run the build to generate the protobuf code. buffa-build shells out to # `protoc`; surface its stderr on failure (a missing protoc is the common case) # instead of exiting silently with nothing written. cd "$TEMP_DIR" if ! cargo build 2>"$TEMP_DIR/build.log"; then cat "$TEMP_DIR/build.log" >&2 - echo "error: prost-build failed; see output above" >&2 + echo "error: buffa-build failed; see output above" >&2 exit 1 fi # Prepend the header to the generated file { - echo "// @generated by prost-build from project_io.proto" + echo "// @generated by buffa-build from project_io.proto" echo "// DO NOT EDIT - regenerate with: pnpm build:gen-protobufs" echo "//" echo "// Proto file SHA256: $PROTO_HASH" - echo "// prost-build version: 0.14" + echo "// buffa-build version: $BUFFA_VERSION" echo "" - cat "$TEMP_DIR/project_io.rs" + cat "$TEMP_DIR/out/project_io.rs" } > "$OUTPUT_FILE" echo "Generated $OUTPUT_FILE" diff --git a/src/libsimlin/Cargo.toml b/src/libsimlin/Cargo.toml index cfe2b8ed9..7aa12f00f 100644 --- a/src/libsimlin/Cargo.toml +++ b/src/libsimlin/Cargo.toml @@ -36,7 +36,6 @@ mimalloc = ["dep:mimalloc"] [dependencies] simlin-engine = { version = "0.1", path = "../simlin-engine", default-features = false } -prost = "0.14" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } anyhow = "1.0" diff --git a/src/libsimlin/src/lib.rs b/src/libsimlin/src/lib.rs index 0ad2d2549..05b4ad47f 100644 --- a/src/libsimlin/src/lib.rs +++ b/src/libsimlin/src/lib.rs @@ -72,7 +72,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::{Arc, Mutex, MutexGuard}; #[cfg(test)] -use prost::Message; +use simlin_engine::buffa::Message; #[cfg(test)] use simlin_engine::serde as engine_serde; #[cfg(test)] @@ -989,9 +989,7 @@ mod tests { use engine::test_common::TestProject; fn open_project_from_datamodel(project: &engine::datamodel::Project) -> *mut SimlinProject { - let pb = engine_serde::serialize(project).unwrap(); - let mut buf = Vec::new(); - pb.encode(&mut buf).unwrap(); + let buf = engine_serde::serialize(project).unwrap().encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf( diff --git a/src/libsimlin/src/project.rs b/src/libsimlin/src/project.rs index 1d769af87..701ac3ed8 100644 --- a/src/libsimlin/src/project.rs +++ b/src/libsimlin/src/project.rs @@ -8,7 +8,7 @@ //! reference counting, querying models, and checking simulatability. use anyhow::{anyhow, Result}; -use prost::Message; +use simlin_engine::buffa::Message; use simlin_engine::{self as engine, serde as engine_serde}; use std::ffi::{CStr, CString}; use std::io::BufReader; @@ -54,10 +54,16 @@ pub unsafe extern "C" fn simlin_project_open_protobuf( } let slice = unsafe { std::slice::from_raw_parts(data, len) }; - let pb_project = engine::project_io::Project::decode(slice).map_err(|decode_err| { - FfiError::new(SimlinErrorCode::ProtobufDecode) - .with_message(format!("failed to decode project protobuf: {decode_err}")) - })?; + // buffa's default decode limits apply, including its 32 MiB budget on + // the memory repeated fields may materialize. That budget is what keeps a + // crafted payload from amplifying into gigabytes, and real projects sit + // far below it: C-LEARN, the largest model in the test corpus, needs + // under a twentieth of it. + let pb_project = + engine::project_io::Project::decode_from_slice(slice).map_err(|decode_err| { + FfiError::new(SimlinErrorCode::ProtobufDecode) + .with_message(format!("failed to decode project protobuf: {decode_err}")) + })?; let datamodel_project: engine::datamodel::Project = engine_serde::deserialize(pb_project); let db = new_synced_db(&datamodel_project); diff --git a/src/libsimlin/src/serialization.rs b/src/libsimlin/src/serialization.rs index 0d51e40b6..aaee6fa14 100644 --- a/src/libsimlin/src/serialization.rs +++ b/src/libsimlin/src/serialization.rs @@ -8,7 +8,7 @@ //! systems, SVG, PNG, and scene formats. The memory for the output buffers is allocated via //! `simlin_malloc` so that callers free it with `simlin_free`. -use prost::Message; +use simlin_engine::buffa::Message; use simlin_engine::{self as engine, serde as engine_serde}; use std::ffi::CStr; use std::os::raw::c_char; @@ -79,15 +79,20 @@ pub unsafe extern "C" fn simlin_project_serialize_protobuf( } }; - let mut bytes = Vec::new(); - if pb_project.encode(&mut bytes).is_err() { - store_error( - out_error, - SimlinError::new(SimlinErrorCode::ProtobufDecode) - .with_message("failed to encode project protobuf"), - ); - return; - } + // The fallible encode: the only failure is a project past protobuf's 2 GiB + // message limit, and the panicking `encode_to_vec` would abort the process + // there (release builds are `panic = abort`) instead of reporting it. + let bytes = match pb_project.try_encode_to_vec() { + Ok(bytes) => bytes, + Err(err) => { + store_error( + out_error, + SimlinError::new(SimlinErrorCode::ProtobufDecode) + .with_message(format!("failed to encode project protobuf: {err}")), + ); + return; + } + }; let len = bytes.len(); let buf = simlin_malloc(len); diff --git a/src/libsimlin/tests/integration/analysis.rs b/src/libsimlin/tests/integration/analysis.rs index 2f5f46a4f..eb4d4b021 100644 --- a/src/libsimlin/tests/integration/analysis.rs +++ b/src/libsimlin/tests/integration/analysis.rs @@ -6,8 +6,8 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::ptr; -use prost::Message; use simlin::*; +use simlin_engine::buffa::Message; use simlin_engine::serde as engine_serde; use simlin_engine::test_common::TestProject; @@ -26,8 +26,7 @@ fn test_get_incoming_links() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -451,8 +450,7 @@ fn test_get_incoming_links_with_private_variables() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -557,8 +555,7 @@ fn test_get_incoming_links_nested_private_vars() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -688,8 +685,7 @@ fn test_analyze_get_links() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -871,8 +867,7 @@ fn test_link_scored_input_count_reports_group_size() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -976,8 +971,7 @@ fn test_relative_link_score_normalizes_per_target() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1090,8 +1084,7 @@ fn test_analyze_get_links_no_loops() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1165,8 +1158,7 @@ fn test_analyze_get_relative_loop_score_renamed() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1261,8 +1253,7 @@ unsafe fn setup_two_loop_sim() -> (*mut SimlinProject, *mut SimlinModel, *mut Si let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); @@ -1478,8 +1469,7 @@ fn test_rel_loop_score_unpartitioned_loops_do_not_cross_normalize() { }); let project = engine_serde::serialize(&p).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1723,9 +1713,7 @@ fn build_arrayed_test_sim_protobuf() -> Vec { .array_flow("births[Region]", "population * birth_rate", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); - buf + project.encode_to_vec() } unsafe fn open_arrayed_sim_with_ltm( @@ -1956,8 +1944,7 @@ fn test_raw_loop_score_per_element_access() { .array_flow("deaths[Region]", "population * 0.1", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let (proj, model, sim) = open_arrayed_sim_with_ltm(&buf); @@ -2155,8 +2142,7 @@ fn test_get_loop_element_count_arrayed_vs_scalar() { .flow("births", "population * 0.05", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf2 = Vec::new(); - project.encode(&mut buf2).unwrap(); + let buf2 = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -2270,8 +2256,7 @@ fn test_two_a2a_subsystems_per_slot_rel_score_round_trips() { ); let pb = engine_serde::serialize(&project).unwrap(); - let mut buf = Vec::new(); - pb.encode(&mut buf).unwrap(); + let buf = pb.encode_to_vec(); unsafe { let (proj, model, sim) = open_arrayed_sim_with_ltm(&buf); @@ -2390,8 +2375,7 @@ unsafe fn open_reinforcing_loop_model() -> (*mut SimlinProject, *mut SimlinModel let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); @@ -2591,8 +2575,7 @@ fn discover_loops_tiny_budget_truncates() { .aux("goal", "1000", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); @@ -2667,8 +2650,7 @@ fn discover_loops_reports_analysis_error_when_ltm_never_ran() { .flow("births", "population * nonexistent_variable", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); @@ -2762,9 +2744,7 @@ fn build_smooth_feedback_protobuf() -> Vec { .flow("adjustment", "gap / 5", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); - buf + project.encode_to_vec() } unsafe fn open_project_and_model(buf: &[u8]) -> (*mut SimlinProject, *mut SimlinModel) { @@ -3005,9 +2985,7 @@ fn build_discovery_with_pin_protobuf() -> Vec { }); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); - buf + project.encode_to_vec() } /// The pinned loop must surface through `simlin_analyze_get_loops` and be @@ -3118,8 +3096,7 @@ fn loop_name_round_trips_through_set_loop_name_patch() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -3223,8 +3200,7 @@ unsafe fn setup_logistic_sign_flip_sim() -> (*mut SimlinProject, *mut SimlinMode let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); @@ -3416,8 +3392,7 @@ fn competing_sign_flip_through_the_c_abi( .flow("f_out", &format!("s * {outflow_gain}"), None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -3531,8 +3506,7 @@ fn runtime_loops_without_run_errors() { .flow("births", "population * 0.1", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -3630,8 +3604,7 @@ fn gh746_arrayed_cycle_runtime_join_is_sound() { .aux("scale", "0.001 * SUM(pool[*]) + 0.01", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let (proj, model, sim) = open_arrayed_sim_with_ltm(&buf); @@ -3740,8 +3713,7 @@ fn runtime_loops_read_slot_width_from_the_sims_own_snapshot() { .array_flow("interest[Region]", "cash * 0.1", None); let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let (proj, model, sim) = open_arrayed_sim_with_ltm(&buf); @@ -3936,8 +3908,7 @@ fn test_cross_element_rel_scores_share_one_partition_denominator_via_ffi() { let project = simlin_engine::open_xmile(&mut std::io::BufReader::new(xml.as_bytes())) .expect("the cross_element fixture parses"); let pb = engine_serde::serialize(&project).unwrap(); - let mut buf = Vec::new(); - pb.encode(&mut buf).unwrap(); + let buf = pb.encode_to_vec(); unsafe { let (proj, model, sim) = open_arrayed_sim_with_ltm(&buf); diff --git a/src/libsimlin/tests/integration/common/mod.rs b/src/libsimlin/tests/integration/common/mod.rs index 54fc91ee5..4e811a998 100644 --- a/src/libsimlin/tests/integration/common/mod.rs +++ b/src/libsimlin/tests/integration/common/mod.rs @@ -2,8 +2,8 @@ // Use of this source code is governed by the Apache License, // Version 2.0, that can be found in the LICENSE file. -use prost::Message; use simlin::*; +use simlin_engine::buffa::Message; use simlin_engine::serde as engine_serde; use std::ffi::CStr; use std::ptr; @@ -46,9 +46,7 @@ pub unsafe fn expect_error_code(err: *mut SimlinError, expected: SimlinErrorCode pub fn open_project_from_datamodel( project: &simlin_engine::datamodel::Project, ) -> *mut SimlinProject { - let pb = engine_serde::serialize(project).unwrap(); - let mut buf = Vec::new(); - pb.encode(&mut buf).unwrap(); + let buf = engine_serde::serialize(project).unwrap().encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf( diff --git a/src/libsimlin/tests/integration/model.rs b/src/libsimlin/tests/integration/model.rs index ed95f6008..76f37032c 100644 --- a/src/libsimlin/tests/integration/model.rs +++ b/src/libsimlin/tests/integration/model.rs @@ -6,9 +6,9 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::ptr; -use prost::Message; use serde_json::Value; use simlin::*; +use simlin_engine::buffa::{Message, MessageField}; use simlin_engine::test_common::TestProject; use simlin_engine::{self as engine}; @@ -770,15 +770,15 @@ fn test_model_functions() { // Create a project with multiple models let project = engine::project_io::Project { name: "test_multi_model".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![ @@ -789,7 +789,7 @@ fn test_model_functions() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "var1".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -801,12 +801,12 @@ fn test_model_functions() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, visibility: engine::project_io::variable::Visibility::Private - as i32, + .into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -814,7 +814,7 @@ fn test_model_functions() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "var2".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -826,12 +826,12 @@ fn test_model_functions() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, visibility: engine::project_io::variable::Visibility::Private - as i32, + .into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -839,7 +839,7 @@ fn test_model_functions() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }, engine::project_io::Model { name: "model2".to_string(), @@ -848,7 +848,7 @@ fn test_model_functions() { v: Some(engine::project_io::variable::V::Stock( engine::project_io::variable::Stock { ident: "stock".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -865,9 +865,9 @@ fn test_model_functions() { non_negative: false, can_be_module_input: false, visibility: engine::project_io::variable::Visibility::Private - as i32, + .into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -875,7 +875,7 @@ fn test_model_functions() { v: Some(engine::project_io::variable::V::Flow( engine::project_io::variable::Flow { ident: "inflow".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -887,13 +887,13 @@ fn test_model_functions() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), non_negative: false, can_be_module_input: false, visibility: engine::project_io::variable::Visibility::Private - as i32, + .into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -901,7 +901,7 @@ fn test_model_functions() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "rate".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -913,12 +913,12 @@ fn test_model_functions() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, visibility: engine::project_io::variable::Visibility::Private - as i32, + .into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -926,16 +926,15 @@ fn test_model_functions() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }, ], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); diff --git a/src/libsimlin/tests/integration/project.rs b/src/libsimlin/tests/integration/project.rs index 6c0437bd8..fb20d1faa 100644 --- a/src/libsimlin/tests/integration/project.rs +++ b/src/libsimlin/tests/integration/project.rs @@ -6,8 +6,8 @@ use std::ffi::{CStr, CString}; use std::ptr; use std::sync::atomic::Ordering; -use prost::Message; use simlin::*; +use simlin_engine::buffa::{Message, MessageField}; use simlin_engine::serde as engine_serde; use simlin_engine::test_common::TestProject; use simlin_engine::{self as engine}; @@ -19,15 +19,15 @@ fn test_project_lifecycle() { // Create a minimal valid protobuf project let project = engine::project_io::Project { name: "test".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -36,14 +36,13 @@ fn test_project_lifecycle() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf( @@ -174,15 +173,15 @@ fn test_project_add_model() { // Create a minimal project with just one model let project = engine::project_io::Project { name: "test_project".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 100.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 0.25, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -191,14 +190,13 @@ fn test_project_add_model() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { // Open the project @@ -330,24 +328,23 @@ fn test_project_add_model_null_safety() { // Create a valid project for other null tests let project = engine::project_io::Project { name: "test".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); @@ -869,8 +866,7 @@ fn test_project_open_roundtrip() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1067,15 +1063,15 @@ fn test_error_api_with_valid_project() { // Create a project with intentional errors let project = engine::project_io::Project { name: "test_errors".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -1086,7 +1082,7 @@ fn test_error_api_with_valid_project() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "error_var".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1098,11 +1094,11 @@ fn test_error_api_with_valid_project() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -1111,7 +1107,7 @@ fn test_error_api_with_valid_project() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "bad_units_var".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1123,11 +1119,11 @@ fn test_error_api_with_valid_project() { }), documentation: String::new(), units: "bad units here!!!".to_string(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -1135,14 +1131,13 @@ fn test_error_api_with_valid_project() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1202,15 +1197,15 @@ fn test_error_api_with_compilation_errors() { // Create a project with compilation errors let project = engine::project_io::Project { name: "test_compilation_errors".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -1221,7 +1216,7 @@ fn test_error_api_with_compilation_errors() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "a".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1233,11 +1228,11 @@ fn test_error_api_with_compilation_errors() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -1245,7 +1240,7 @@ fn test_error_api_with_compilation_errors() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "b".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1257,11 +1252,11 @@ fn test_error_api_with_compilation_errors() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }, @@ -1269,14 +1264,13 @@ fn test_error_api_with_compilation_errors() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1322,15 +1316,15 @@ fn test_error_api_no_errors() { // Create a valid project with no errors let project = engine::project_io::Project { name: "test_no_errors".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -1339,7 +1333,7 @@ fn test_error_api_no_errors() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "time_var".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1351,25 +1345,24 @@ fn test_error_api_no_errors() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }], views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1394,15 +1387,15 @@ fn test_get_errors_repeated_calls_reuse_sync_state() { // salsa inputs on every call (which would cause unbounded DB growth). let project = engine::project_io::Project { name: "repeated_errors".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -1411,7 +1404,7 @@ fn test_get_errors_repeated_calls_reuse_sync_state() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "x".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1423,27 +1416,25 @@ fn test_get_errors_repeated_calls_reuse_sync_state() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }], views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - use prost::Message; - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1483,15 +1474,15 @@ fn test_error_offsets() { // Create a project with an error at a specific location let project = engine::project_io::Project { name: "test_offsets".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -1500,7 +1491,7 @@ fn test_error_offsets() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "var_with_offset_error".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1512,25 +1503,24 @@ fn test_error_offsets() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }], views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -1664,8 +1654,8 @@ fn test_stdlib_models_present_after_json_open() { assert!(!pb_buf.is_null()); let pb_bytes = std::slice::from_raw_parts(pb_buf, pb_len); - let pb_project = - engine::project_io::Project::decode(pb_bytes).expect("protobuf decode failed"); + let pb_project = engine::project_io::Project::decode_from_slice(pb_bytes) + .expect("protobuf decode failed"); let pb_model_names: Vec<&str> = pb_project.models.iter().map(|m| m.name.as_str()).collect(); assert!( !pb_model_names.iter().any(|n| n.starts_with("stdlib")), diff --git a/src/libsimlin/tests/integration/rendering.rs b/src/libsimlin/tests/integration/rendering.rs index 0d036e2c2..582a883df 100644 --- a/src/libsimlin/tests/integration/rendering.rs +++ b/src/libsimlin/tests/integration/rendering.rs @@ -100,7 +100,10 @@ fn test_render_svg_generates_layout_for_viewless_model() { ); crate::common::expect_no_error(ser_err, "serialize after render"); let roundtripped: simlin_engine::project_io::Project = - prost::Message::decode(std::slice::from_raw_parts(ser_buf, ser_len)).unwrap(); + simlin_engine::buffa::Message::decode_from_slice(std::slice::from_raw_parts( + ser_buf, ser_len, + )) + .unwrap(); let deserialized = simlin_engine::serde::deserialize(roundtripped); let model = deserialized.get_model("main").unwrap(); assert!( @@ -342,7 +345,10 @@ fn test_render_scene_generates_layout_for_viewless_model() { ); crate::common::expect_no_error(ser_err, "serialize after render"); let roundtripped: simlin_engine::project_io::Project = - prost::Message::decode(std::slice::from_raw_parts(ser_buf, ser_len)).unwrap(); + simlin_engine::buffa::Message::decode_from_slice(std::slice::from_raw_parts( + ser_buf, ser_len, + )) + .unwrap(); let deserialized = simlin_engine::serde::deserialize(roundtripped); assert!( deserialized.get_model("main").unwrap().views.is_empty(), diff --git a/src/libsimlin/tests/integration/serialization.rs b/src/libsimlin/tests/integration/serialization.rs index f2f979689..13f66f21a 100644 --- a/src/libsimlin/tests/integration/serialization.rs +++ b/src/libsimlin/tests/integration/serialization.rs @@ -5,9 +5,9 @@ use std::ffi::CStr; use std::ptr; -use prost::Message; use serde_json::Value; use simlin::*; +use simlin_engine::buffa::{Message, MessageField}; use simlin_engine::serde as engine_serde; use simlin_engine::test_common::TestProject; use simlin_engine::{self as engine}; @@ -321,8 +321,7 @@ fn test_project_serialize() { let datamodel_project = test_project.build_datamodel(); let original_pb = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - original_pb.encode(&mut buf).unwrap(); + let buf = original_pb.encode_to_vec(); unsafe { // Open the project @@ -446,8 +445,7 @@ fn test_project_serialize_with_ltm() { let datamodel_project = test_project.build_datamodel(); let original_pb = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - original_pb.encode(&mut buf).unwrap(); + let buf = original_pb.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); @@ -559,15 +557,15 @@ fn test_project_serialize_null_safety() { // Test with null output pointer let project = engine::project_io::Project { name: "test".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -576,14 +574,13 @@ fn test_project_serialize_null_safety() { views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf(buf.as_ptr(), buf.len(), &mut err); diff --git a/src/libsimlin/tests/integration/simulation.rs b/src/libsimlin/tests/integration/simulation.rs index 7f4c213fb..4e689e552 100644 --- a/src/libsimlin/tests/integration/simulation.rs +++ b/src/libsimlin/tests/integration/simulation.rs @@ -7,8 +7,8 @@ use std::os::raw::{c_char, c_double}; use std::ptr; use std::sync::atomic::Ordering; -use prost::Message; use simlin::*; +use simlin_engine::buffa::{Message, MessageField}; use simlin_engine::serde as engine_serde; use simlin_engine::test_common::TestProject; use simlin_engine::{self as engine}; @@ -1048,15 +1048,15 @@ fn test_sim_lifecycle() { // Create a minimal valid protobuf project let project = engine::project_io::Project { name: "test".to_string(), - sim_specs: Some(engine::project_io::SimSpecs { + sim_specs: MessageField::some(engine::project_io::SimSpecs { start: 0.0, stop: 10.0, - dt: Some(engine::project_io::Dt { + dt: MessageField::some(engine::project_io::Dt { value: 1.0, is_reciprocal: false, }), - save_step: None, - sim_method: engine::project_io::SimMethod::Euler as i32, + save_step: MessageField::none(), + sim_method: engine::project_io::SimMethod::Euler.into(), time_units: None, }), models: vec![engine::project_io::Model { @@ -1065,7 +1065,7 @@ fn test_sim_lifecycle() { v: Some(engine::project_io::variable::V::Aux( engine::project_io::variable::Aux { ident: "time".to_string(), - equation: Some(engine::project_io::variable::Equation { + equation: MessageField::some(engine::project_io::variable::Equation { equation: Some( engine::project_io::variable::equation::Equation::Scalar( engine::project_io::variable::ScalarEquation { @@ -1077,25 +1077,24 @@ fn test_sim_lifecycle() { }), documentation: String::new(), units: String::new(), - gf: None, + gf: MessageField::none(), can_be_module_input: false, - visibility: engine::project_io::variable::Visibility::Private as i32, + visibility: engine::project_io::variable::Visibility::Private.into(), uid: 0, - compat: None, + compat: MessageField::none(), }, )), }], views: vec![], loop_metadata: vec![], groups: vec![], - macro_spec: None, + macro_spec: MessageField::none(), }], dimensions: vec![], units: vec![], - source: None, + source: MessageField::none(), }; - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); let proj = simlin_project_open_protobuf( @@ -1157,8 +1156,7 @@ fn test_ltm_enabled_sim() { let datamodel_project = test_project.build_datamodel(); let project = engine_serde::serialize(&datamodel_project).unwrap(); - let mut buf = Vec::new(); - project.encode(&mut buf).unwrap(); + let buf = project.encode_to_vec(); unsafe { let mut err: *mut SimlinError = ptr::null_mut(); diff --git a/src/simlin-cli/src/main.rs b/src/simlin-cli/src/main.rs index ee845efd9..a5f310849 100644 --- a/src/simlin-cli/src/main.rs +++ b/src/simlin-cli/src/main.rs @@ -20,6 +20,7 @@ use std::result::Result as StdResult; use clap::{Args, Parser, Subcommand, ValueEnum}; +use simlin_engine::buffa::Message; use simlin_engine::common::ErrorKind; use simlin_engine::data_provider::FilesystemDataProvider; use simlin_engine::datamodel::Project as DatamodelProject; @@ -32,7 +33,6 @@ use simlin_engine::errors::{ FormattedError, FormattedErrorKind, FormattedErrors, collect_formatted_errors, format_simulation_error, }; -use simlin_engine::prost::Message; use simlin_engine::{Error, ErrorCode, Result, Results, build_sim, datamodel, project_io, serde}; use simlin_engine::{ load_csv, load_dat, open_vensim, open_vensim_with_data, open_xmile, to_mdl_with_warnings, @@ -322,16 +322,18 @@ fn open_vensim_model(path: Option<&Path>, contents: &str) -> Result Result { + // The whole input: a protobuf is binary, and any field holding a zero byte + // (a `double` like `dt = 1.0`) would end a delimiter-bounded read early. let mut contents_buf: Vec = vec![]; - reader.read_until(0, &mut contents_buf).map_err(|_err| { + reader.read_to_end(&mut contents_buf).map_err(|err| { Error::new( ErrorKind::Import, ErrorCode::VensimConversion, - Some("1".to_owned()), + Some(format!("reading protobuf input: {err}")), ) })?; - let project = match project_io::Project::decode(&*contents_buf) { + let project = match project_io::Project::decode_from_slice(&contents_buf) { Ok(project) => serde::deserialize(project), Err(err) => { return Err(Error::new( @@ -824,13 +826,9 @@ fn main() { if pb_project.models.len() != 1 { die!("--model-only specified, but more than 1 model in this project"); } - let mut buf = Vec::with_capacity(pb_project.models[0].encoded_len()); - pb_project.models[0].encode(&mut buf).unwrap(); - buf + pb_project.models[0].encode_to_vec() } else { - let mut buf = Vec::with_capacity(pb_project.encoded_len()); - pb_project.encode(&mut buf).unwrap(); - buf + pb_project.encode_to_vec() } } }; @@ -906,6 +904,53 @@ mod open_model_tests { } } +#[cfg(test)] +mod open_binary_tests { + use super::*; + + fn teacup_protobuf() -> (DatamodelProject, Vec) { + let path = concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../test/test-models/samples/teacup/teacup_w_diagram.xmile" + ); + let bytes = std::fs::read(path).unwrap_or_else(|e| panic!("failed to read {path}: {e}")); + let project = open_xmile(&mut BufReader::new(bytes.as_slice())) + .unwrap_or_else(|e| panic!("failed to parse {path}: {e}")); + let encoded = serde::serialize(&project).unwrap().encode_to_vec(); + (project, encoded) + } + + /// A protobuf project reads back whole. Every real project's encoding + /// holds zero bytes (`dt = 1.0` alone is six of them), so a reader that + /// stops at a delimiter hands the decoder a truncated message. + #[test] + fn a_protobuf_project_reads_back_whole() { + let (project, encoded) = teacup_protobuf(); + assert!( + encoded.contains(&0), + "the fixture must carry a zero byte to exercise the whole read" + ); + + let decoded = open_binary(&mut BufReader::new(encoded.as_slice())) + .unwrap_or_else(|e| panic!("the encoded project decodes: {e}")); + assert_eq!( + decoded, + serde::deserialize(serde::serialize(&project).unwrap()) + ); + } + + /// Bytes that are not a whole project are refused with the decoder's + /// reason, never a panic. + #[test] + fn a_truncated_protobuf_is_refused() { + let (_, encoded) = teacup_protobuf(); + let truncated = &encoded[..encoded.len() / 2]; + let err = open_binary(&mut BufReader::new(truncated)) + .expect_err("half a message is not a project"); + assert_eq!(err.code, ErrorCode::VensimConversion); + } +} + #[cfg(test)] mod render_tests { use super::*; diff --git a/src/simlin-engine/Cargo.toml b/src/simlin-engine/Cargo.toml index cf51a6168..24e3d0a5f 100644 --- a/src/simlin-engine/Cargo.toml +++ b/src/simlin-engine/Cargo.toml @@ -42,7 +42,10 @@ layout_eval = [] [dependencies] unicode-xid = "0.2" -prost = "0.14" +# Protobuf runtime for the checked-in `src/project_io.gen.rs`. The generator in +# scripts/gen-rust-protobufs.sh pins buffa-build to the version Cargo.lock +# resolves this to, so bumping it means regenerating. +buffa = "0.9" smallvec = { version = "1", features = [ "union" ] } # Fast, deterministic (fixed-seed) hasher for hot internal maps in the # dependency-graph cycle gate. Wasm-safe (no getrandom). FxHash's fixed seed diff --git a/src/simlin-engine/src/json_proptest.rs b/src/simlin-engine/src/json_proptest.rs index d0f162e8f..c4665ef07 100644 --- a/src/simlin-engine/src/json_proptest.rs +++ b/src/simlin-engine/src/json_proptest.rs @@ -1092,19 +1092,18 @@ proptest! { /// Returns (protobuf_bytes, json_string) fn roundtrip_pb_json(json_project: &Project) -> (Vec, String) { use crate::project_io; - use crate::prost::Message; use crate::serde as project_serde; + use buffa::Message; // json -> datamodel -> protobuf let dm_project: datamodel::Project = json_project.clone().into(); let pb_project: project_io::Project = project_serde::serialize(&dm_project).unwrap(); // Encode to protobuf bytes - let mut pb_bytes = Vec::new(); - pb_project.encode(&mut pb_bytes).unwrap(); + let pb_bytes = pb_project.encode_to_vec(); // Decode protobuf bytes - let pb_decoded = project_io::Project::decode(&pb_bytes[..]).unwrap(); + let pb_decoded = project_io::Project::decode_from_slice(&pb_bytes).unwrap(); // protobuf -> datamodel -> json -> string let dm_decoded: datamodel::Project = project_serde::deserialize(pb_decoded); @@ -1152,29 +1151,26 @@ proptest! { /// migration use case. #[test] fn protobuf_roundtrip_is_idempotent(project in project_strategy()) { - use crate::prost::Message; use crate::project_io; use crate::serde as project_serde; + use buffa::Message; // First roundtrip: json -> datamodel -> protobuf -> bytes let dm1: datamodel::Project = project.clone().into(); let pb1: project_io::Project = project_serde::serialize(&dm1).unwrap(); - let mut pb_bytes1 = Vec::new(); - pb1.encode(&mut pb_bytes1).unwrap(); + let pb_bytes1 = pb1.encode_to_vec(); // Decode and do second roundtrip - let pb1_decoded = project_io::Project::decode(&pb_bytes1[..]).unwrap(); + let pb1_decoded = project_io::Project::decode_from_slice(&pb_bytes1).unwrap(); let dm2: datamodel::Project = project_serde::deserialize(pb1_decoded); let pb2: project_io::Project = project_serde::serialize(&dm2).unwrap(); - let mut pb_bytes2 = Vec::new(); - pb2.encode(&mut pb_bytes2).unwrap(); + let pb_bytes2 = pb2.encode_to_vec(); // Third roundtrip - let pb2_decoded = project_io::Project::decode(&pb_bytes2[..]).unwrap(); + let pb2_decoded = project_io::Project::decode_from_slice(&pb_bytes2).unwrap(); let dm3: datamodel::Project = project_serde::deserialize(pb2_decoded); let pb3: project_io::Project = project_serde::serialize(&dm3).unwrap(); - let mut pb_bytes3 = Vec::new(); - pb3.encode(&mut pb_bytes3).unwrap(); + let pb_bytes3 = pb3.encode_to_vec(); // After first roundtrip, datamodel and protobuf bytes should be stable prop_assert_eq!(&dm2, &dm3); @@ -1186,8 +1182,8 @@ proptest! { mod protobuf_roundtrip_tests { use super::*; use crate::project_io; - use crate::prost::Message; use crate::serde as project_serde; + use buffa::Message; use std::fs; use std::path::Path; @@ -1210,7 +1206,7 @@ mod protobuf_roundtrip_tests { .unwrap_or_else(|_| panic!("Failed to read {}", proto_path.display())); // Decode the original protobuf - let pb_original = project_io::Project::decode(&proto_bytes[..]) + let pb_original = project_io::Project::decode_from_slice(&proto_bytes) .unwrap_or_else(|_| panic!("Failed to decode {}", filename)); // Convert to datamodel diff --git a/src/simlin-engine/src/json_sdai_proptest.rs b/src/simlin-engine/src/json_sdai_proptest.rs index 859958ffe..69e5eb5b3 100644 --- a/src/simlin-engine/src/json_sdai_proptest.rs +++ b/src/simlin-engine/src/json_sdai_proptest.rs @@ -821,8 +821,8 @@ mod schema_tests { mod protobuf_roundtrip_tests { use super::*; use crate::project_io; - use crate::prost::Message; use crate::serde as project_serde; + use buffa::Message; /// Performs a full protobuf -> JSON roundtrip for SDAI models: /// 1. Converts SdaiModel to datamodel::Project @@ -837,11 +837,10 @@ mod protobuf_roundtrip_tests { let pb_project: project_io::Project = project_serde::serialize(&dm_project).unwrap(); // Encode to protobuf bytes - let mut pb_bytes = Vec::new(); - pb_project.encode(&mut pb_bytes).unwrap(); + let pb_bytes = pb_project.encode_to_vec(); // Decode protobuf bytes - let pb_decoded = project_io::Project::decode(&pb_bytes[..]).unwrap(); + let pb_decoded = project_io::Project::decode_from_slice(&pb_bytes).unwrap(); // protobuf -> datamodel -> sdai -> string let dm_decoded: datamodel::Project = project_serde::deserialize(pb_decoded); diff --git a/src/simlin-engine/src/lib.rs b/src/simlin-engine/src/lib.rs index 5944845ff..80dbc42a3 100644 --- a/src/simlin-engine/src/lib.rs +++ b/src/simlin-engine/src/lib.rs @@ -10,7 +10,11 @@ // statically validates that compiled bytecode cannot exceed STACK_CAPACITY. #![deny(unsafe_code)] -pub use prost; +// Re-exported so downstream crates (libsimlin, simlin-cli) encode and decode +// `project_io` messages through the same runtime the generated code was built +// against, instead of each declaring a `buffa` version of its own that has to +// track this crate's. +pub use buffa; // Re-exported so downstream crates (libsimlin, integration tests) can name the // `IndexMap` type of `db::LtmVariablesResult.loop_partitions` without taking a // direct `indexmap` dependency. The emission-order iteration is load-bearing @@ -79,7 +83,13 @@ mod parser; mod patch; #[cfg(test)] mod per_element_gf_tests; -#[allow(clippy::derive_partial_eq_without_eq)] +// Generated code: silence the lints buffa-codegen's output trips rather than +// hand-editing a file the freshness test regenerates. +#[allow( + clippy::derive_partial_eq_without_eq, + clippy::derivable_impls, + clippy::match_single_binding +)] #[path = "project_io.gen.rs"] pub mod project_io; pub mod queue; diff --git a/src/simlin-engine/src/ltm/tests.rs b/src/simlin-engine/src/ltm/tests.rs index e265a4ee3..93e1e5b65 100644 --- a/src/simlin-engine/src/ltm/tests.rs +++ b/src/simlin-engine/src/ltm/tests.rs @@ -1090,12 +1090,12 @@ fn test_lookup_table_polarity_defensive_subscript_branches() { #[test] fn test_fishbanks_loops() { - use crate::prost::Message; + use buffa::Message; use std::fs; let proto_bytes = fs::read("../../test/fishbanks.protobin").expect("Failed to read fishbanks.protobin file"); - let project_io = crate::project_io::Project::decode(&proto_bytes[..]) + let project_io = crate::project_io::Project::decode_from_slice(&proto_bytes) .expect("Failed to decode fishbanks.protobin"); let datamodel_project = crate::serde::deserialize(project_io); @@ -1167,12 +1167,12 @@ fn test_fishbanks_loops() { #[test] fn test_logistic_growth_loops() { - use crate::prost::Message; + use buffa::Message; use std::fs; let proto_bytes = fs::read("../../test/logistic-growth.protobin") .expect("Failed to read logistic-growth.protobin file"); - let project_io = crate::project_io::Project::decode(&proto_bytes[..]) + let project_io = crate::project_io::Project::decode_from_slice(&proto_bytes) .expect("Failed to decode logistic-growth.protobin"); let datamodel_project = crate::serde::deserialize(project_io); diff --git a/src/simlin-engine/src/project_io.gen.rs b/src/simlin-engine/src/project_io.gen.rs index ab6207c74..677d98870 100644 --- a/src/simlin-engine/src/project_io.gen.rs +++ b/src/simlin-engine/src/project_io.gen.rs @@ -1,1110 +1,10558 @@ -// @generated by prost-build from project_io.proto +// @generated by buffa-build from project_io.proto // DO NOT EDIT - regenerate with: pnpm build:gen-protobufs // -// Proto file SHA256: fc8496fe5d4ca7d87f6b1ecab9af9d453ca94a50c482eb6727e1127e4da59512 -// prost-build version: 0.14 +// Proto file SHA256: 1bbf355a07397b96a38ed4e0133f5b2d8bd6fc817a8ec24a890404114c3a49dc +// buffa-build version: 0.9.2 -// This file is @generated by prost-build. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GraphicalFunction { - #[prost(enumeration = "graphical_function::Kind", tag = "1")] - pub kind: i32, - #[prost(double, repeated, tag = "2")] - pub x_points: ::prost::alloc::vec::Vec, - #[prost(double, repeated, tag = "3")] - pub y_points: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "4")] - pub x_scale: ::core::option::Option, - #[prost(message, optional, tag = "5")] - pub y_scale: ::core::option::Option, -} -/// Nested message and enum types in `GraphicalFunction`. -pub mod graphical_function { - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct Scale { - #[prost(double, tag = "1")] - pub min: f64, - #[prost(double, tag = "2")] - pub max: f64, +// @generated by buffa-codegen. DO NOT EDIT. + +#[allow(non_camel_case_types)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SimMethod { + EULER = 0i32, + RUNGE_KUTTA_4 = 1i32, + RUNGE_KUTTA_2 = 3i32, +} +impl SimMethod { + ///Idiomatic alias for [`Self::EULER`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Euler: Self = Self::EULER; + ///Idiomatic alias for [`Self::RUNGE_KUTTA_4`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RungeKutta4: Self = Self::RUNGE_KUTTA_4; + ///Idiomatic alias for [`Self::RUNGE_KUTTA_2`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RungeKutta2: Self = Self::RUNGE_KUTTA_2; +} +impl ::core::default::Default for SimMethod { + fn default() -> Self { + Self::EULER } - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum Kind { - Continuous = 0, - Discrete = 1, - Extrapolate = 2, +} +impl ::buffa::Enumeration for SimMethod { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::EULER), + 1i32 => ::core::option::Option::Some(Self::RUNGE_KUTTA_4), + 3i32 => ::core::option::Option::Some(Self::RUNGE_KUTTA_2), + _ => ::core::option::Option::None, + } } - impl Kind { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Continuous => "CONTINUOUS", - Self::Discrete => "DISCRETE", - Self::Extrapolate => "EXTRAPOLATE", - } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::EULER => "EULER", + Self::RUNGE_KUTTA_4 => "RUNGE_KUTTA_4", + Self::RUNGE_KUTTA_2 => "RUNGE_KUTTA_2", } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "CONTINUOUS" => Some(Self::Continuous), - "DISCRETE" => Some(Self::Discrete), - "EXTRAPOLATE" => Some(Self::Extrapolate), - _ => None, - } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "EULER" => ::core::option::Option::Some(Self::EULER), + "RUNGE_KUTTA_4" => ::core::option::Option::Some(Self::RUNGE_KUTTA_4), + "RUNGE_KUTTA_2" => ::core::option::Option::Some(Self::RUNGE_KUTTA_2), + _ => ::core::option::Option::None, } } + fn values() -> &'static [Self] { + &[Self::EULER, Self::RUNGE_KUTTA_4, Self::RUNGE_KUTTA_2] + } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Variable { - #[prost(oneof = "variable::V", tags = "1, 2, 3, 4")] - pub v: ::core::option::Option, +#[derive(Clone, PartialEq, Default)] +pub struct GraphicalFunction { + /// Field 1: `kind` + pub kind: ::buffa::EnumValue, + /// Field 2: `x_points` + pub x_points: ::buffa::alloc::vec::Vec, + /// Field 3: `y_points` + pub y_points: ::buffa::alloc::vec::Vec, + /// Field 4: `x_scale` + pub x_scale: ::buffa::MessageField< + graphical_function::Scale, + ::buffa::Inline, + >, + /// Field 5: `y_scale` + pub y_scale: ::buffa::MessageField< + graphical_function::Scale, + ::buffa::Inline, + >, } -/// Nested message and enum types in `Variable`. -pub mod variable { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct ScalarEquation { - #[prost(string, tag = "1")] - pub equation: ::prost::alloc::string::String, - #[prost(string, optional, tag = "2")] - pub initial_equation: ::core::option::Option<::prost::alloc::string::String>, - } - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct ApplyToAllEquation { - #[prost(string, repeated, tag = "1")] - pub dimension_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, tag = "2")] - pub equation: ::prost::alloc::string::String, - #[prost(string, optional, tag = "3")] - pub initial_equation: ::core::option::Option<::prost::alloc::string::String>, - } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ArrayedEquation { - #[prost(string, repeated, tag = "1")] - pub dimension_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub elements: ::prost::alloc::vec::Vec, - #[prost(bool, optional, tag = "3")] - pub has_except_default: ::core::option::Option, - #[prost(string, optional, tag = "4")] - pub default_equation: ::core::option::Option<::prost::alloc::string::String>, +impl ::core::fmt::Debug for GraphicalFunction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GraphicalFunction") + .field("kind", &self.kind) + .field("x_points", &self.x_points) + .field("y_points", &self.y_points) + .field("x_scale", &self.x_scale) + .field("y_scale", &self.y_scale) + .finish() } - /// Nested message and enum types in `ArrayedEquation`. - pub mod arrayed_equation { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Element { - #[prost(string, tag = "1")] - pub subscript: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub equation: ::prost::alloc::string::String, - #[prost(string, optional, tag = "3")] - pub initial_equation: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, optional, tag = "4")] - pub gf: ::core::option::Option, +} +impl GraphicalFunction { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.GraphicalFunction"; +} +::buffa::impl_default_instance!(GraphicalFunction); +impl ::buffa::MessageName for GraphicalFunction { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "GraphicalFunction"; + const FULL_NAME: &'static str = "project_io.GraphicalFunction"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.GraphicalFunction"; +} +impl ::buffa::Message for GraphicalFunction { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } } - } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Equation { - #[prost(oneof = "equation::Equation", tags = "1, 2, 3")] - pub equation: ::core::option::Option, - } - /// Nested message and enum types in `Equation`. - pub mod equation { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Equation { - #[prost(message, tag = "1")] - Scalar(super::ScalarEquation), - #[prost(message, tag = "2")] - ApplyToAll(super::ApplyToAllEquation), - #[prost(message, tag = "3")] - Arrayed(super::ArrayedEquation), + if !self.x_points.is_empty() { + let payload: u64 = + self.x_points.len() as u64 * ::buffa::types::FIXED64_ENCODED_LEN as u64; + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if !self.y_points.is_empty() { + let payload: u64 = + self.y_points.len() as u64 * ::buffa::types::FIXED64_ENCODED_LEN as u64; + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.x_scale.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.x_scale.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; } + if self.y_scale.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.y_scale.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) } - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct DataSource { - #[prost(enumeration = "data_source::Kind", tag = "1")] - pub kind: i32, - #[prost(string, tag = "2")] - pub file: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub tab_or_delimiter: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub row_or_col: ::prost::alloc::string::String, - #[prost(string, tag = "5")] - pub cell: ::prost::alloc::string::String, - } - /// Nested message and enum types in `DataSource`. - pub mod data_source { - #[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, - )] - #[repr(i32)] - pub enum Kind { - Data = 0, - Constants = 1, - Lookups = 2, - Subscript = 3, + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.kind.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(1u32, val, buf); + } } - impl Kind { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Data => "DATA", - Self::Constants => "CONSTANTS", - Self::Lookups => "LOOKUPS", - Self::Subscript => "SUBSCRIPT", + if !self.x_points.is_empty() { + let payload: u64 = + self.x_points.len() as u64 * ::buffa::types::FIXED64_ENCODED_LEN as u64; + ::buffa::types::put_len_delimited_header(2u32, payload, buf); + for &v in &self.x_points { + ::buffa::types::encode_double(v, buf); + } + } + if !self.y_points.is_empty() { + let payload: u64 = + self.y_points.len() as u64 * ::buffa::types::FIXED64_ENCODED_LEN as u64; + ::buffa::types::put_len_delimited_header(3u32, payload, buf); + for &v in &self.y_points { + ::buffa::types::encode_double(v, buf); + } + } + if self.x_scale.is_set() { + ::buffa::types::put_len_delimited_header(4u32, u64::from(__cache.consume_next()), buf); + self.x_scale.write_to(__cache, buf); + } + if self.y_scale.is_set() { + ::buffa::types::put_len_delimited_header(5u32, u64::from(__cache.consume_next()), buf); + self.y_scale.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = + usize::try_from(len).map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err(::buffa::DecodeError::UnexpectedEof); + } + if buf.chunk().len() >= len { + ::buffa::types::extend_packed_double( + &buf.chunk()[..len], + &mut self.x_points, + )?; + buf.advance(len); + } else { + self.x_points.reserve(len / 8usize); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.x_points + .push(::buffa::types::decode_double(&mut limited)?); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Fixed64 { + self.x_points.push(::buffa::types::decode_double(buf)?); + } else { + return ::core::result::Result::Err(::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )); } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "DATA" => Some(Self::Data), - "CONSTANTS" => Some(Self::Constants), - "LOOKUPS" => Some(Self::Lookups), - "SUBSCRIPT" => Some(Self::Subscript), - _ => None, + 3u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = + usize::try_from(len).map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err(::buffa::DecodeError::UnexpectedEof); + } + if buf.chunk().len() >= len { + ::buffa::types::extend_packed_double( + &buf.chunk()[..len], + &mut self.y_points, + )?; + buf.advance(len); + } else { + self.y_points.reserve(len / 8usize); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.y_points + .push(::buffa::types::decode_double(&mut limited)?); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Fixed64 { + self.y_points.push(::buffa::types::decode_double(buf)?); + } else { + return ::core::result::Result::Err(::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )); } } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.x_scale.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.y_scale.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } } + ::core::result::Result::Ok(()) } - /// A conveyor stock's belt parameters. See docs/design/conveyors.md. - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct Conveyor { - /// (required) - #[prost(string, tag = "1")] - pub transit_time: ::prost::alloc::string::String, - /// - #[prost(string, optional, tag = "2")] - pub capacity: ::core::option::Option<::prost::alloc::string::String>, - /// - #[prost(string, optional, tag = "3")] - pub inflow_limit: ::core::option::Option<::prost::alloc::string::String>, - /// - #[prost(string, optional, tag = "4")] - pub sample: ::core::option::Option<::prost::alloc::string::String>, - /// - #[prost(string, optional, tag = "5")] - pub arrest: ::core::option::Option<::prost::alloc::string::String>, - #[prost(bool, tag = "6")] - pub discrete: bool, - #[prost(bool, tag = "7")] - pub batch_integrity: bool, - /// default true - #[prost(bool, tag = "8")] - pub one_at_a_time: bool, - #[prost(bool, tag = "9")] - pub exponential_leak: bool, - #[prost(bool, tag = "10")] - pub ignore_earlier_zone_losses: bool, + fn clear(&mut self) { + self.kind = ::buffa::EnumValue::from(0); + self.x_points.clear(); + self.y_points.clear(); + self.x_scale = ::buffa::MessageField::none(); + self.y_scale = ::buffa::MessageField::none(); } - /// Marks a flow as a conveyor leakage outflow. - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct Leakage { - /// None for a bare marker - #[prost(string, optional, tag = "1")] - pub fraction: ::core::option::Option<::prost::alloc::string::String>, - /// - #[prost(bool, tag = "2")] - pub integers: bool, - /// leak_start - #[prost(string, optional, tag = "3")] - pub zone_start: ::core::option::Option<::prost::alloc::string::String>, - /// leak_end - #[prost(string, optional, tag = "4")] - pub zone_end: ::core::option::Option<::prost::alloc::string::String>, +} +pub mod graphical_function { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum Kind { + CONTINUOUS = 0i32, + DISCRETE = 1i32, + EXTRAPOLATE = 2i32, } - /// isee:spreadflow inflow placement method. - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct SpreadFlow { - #[prost(enumeration = "spread_flow::Method", tag = "1")] - pub method: i32, - /// graphical-function name for DIST - #[prost(string, optional, tag = "2")] - pub distrib_eq: ::core::option::Option<::prost::alloc::string::String>, + impl Kind { + ///Idiomatic alias for [`Self::CONTINUOUS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Continuous: Self = Self::CONTINUOUS; + ///Idiomatic alias for [`Self::DISCRETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Discrete: Self = Self::DISCRETE; + ///Idiomatic alias for [`Self::EXTRAPOLATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Extrapolate: Self = Self::EXTRAPOLATE; } - /// Nested message and enum types in `SpreadFlow`. - pub mod spread_flow { - #[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, - )] - #[repr(i32)] - pub enum Method { - Beginning = 0, - Even = 1, - Dest = 2, - Dist = 3, - Source = 4, + impl ::core::default::Default for Kind { + fn default() -> Self { + Self::CONTINUOUS } - impl Method { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Beginning => "BEGINNING", - Self::Even => "EVEN", - Self::Dest => "DEST", - Self::Dist => "DIST", - Self::Source => "SOURCE", - } + } + impl ::buffa::Enumeration for Kind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CONTINUOUS), + 1i32 => ::core::option::Option::Some(Self::DISCRETE), + 2i32 => ::core::option::Option::Some(Self::EXTRAPOLATE), + _ => ::core::option::Option::None, } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "BEGINNING" => Some(Self::Beginning), - "EVEN" => Some(Self::Even), - "DEST" => Some(Self::Dest), - "DIST" => Some(Self::Dist), - "SOURCE" => Some(Self::Source), - _ => None, - } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CONTINUOUS => "CONTINUOUS", + Self::DISCRETE => "DISCRETE", + Self::EXTRAPOLATE => "EXTRAPOLATE", } } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CONTINUOUS" => ::core::option::Option::Some(Self::CONTINUOUS), + "DISCRETE" => ::core::option::Option::Some(Self::DISCRETE), + "EXTRAPOLATE" => ::core::option::Option::Some(Self::EXTRAPOLATE), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[Self::CONTINUOUS, Self::DISCRETE, Self::EXTRAPOLATE] + } } - /// A queue stock has no options (XMILE §4.2). See docs/design/queues.md. - #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] - pub struct Queue {} - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct Compat { - #[prost(string, optional, tag = "1")] - pub active_initial: ::core::option::Option<::prost::alloc::string::String>, - #[prost(bool, optional, tag = "2")] - pub non_negative: ::core::option::Option, - #[prost(bool, optional, tag = "3")] - pub can_be_module_input: ::core::option::Option, - #[prost(enumeration = "Visibility", optional, tag = "4")] - pub visibility: ::core::option::Option, - #[prost(message, optional, tag = "5")] - pub data_source: ::core::option::Option, - #[prost(message, optional, tag = "6")] - pub conveyor: ::core::option::Option, - #[prost(message, optional, tag = "7")] - pub leakage: ::core::option::Option, - #[prost(message, optional, tag = "8")] - pub spreadflow: ::core::option::Option, - /// present iff a queue stock () - #[prost(message, optional, tag = "9")] - pub queue: ::core::option::Option, - /// on a queue outflow - #[prost(bool, tag = "10")] - pub overflow: bool, + #[derive(Clone, PartialEq, Default)] + pub struct Scale { + /// Field 1: `min` + pub min: f64, + /// Field 2: `max` + pub max: f64, } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Stock { - #[prost(string, tag = "1")] - pub ident: ::prost::alloc::string::String, - #[prost(message, optional, tag = "8")] - pub equation: ::core::option::Option, - #[prost(string, tag = "3")] - pub documentation: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub units: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "5")] - pub inflows: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "6")] - pub outflows: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(bool, tag = "7")] - pub non_negative: bool, - #[prost(bool, tag = "9")] - pub can_be_module_input: bool, - #[prost(enumeration = "Visibility", tag = "10")] - pub visibility: i32, - #[prost(int32, tag = "11")] - pub uid: i32, - #[prost(message, optional, tag = "12")] - pub compat: ::core::option::Option, + impl ::core::fmt::Debug for Scale { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Scale") + .field("min", &self.min) + .field("max", &self.max) + .finish() + } } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Flow { - #[prost(string, tag = "1")] - pub ident: ::prost::alloc::string::String, - #[prost(message, optional, tag = "8")] - pub equation: ::core::option::Option, - #[prost(string, tag = "3")] - pub documentation: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub units: ::prost::alloc::string::String, - #[prost(message, optional, tag = "5")] - pub gf: ::core::option::Option, - #[prost(bool, tag = "7")] - pub non_negative: bool, - #[prost(bool, tag = "9")] - pub can_be_module_input: bool, - #[prost(enumeration = "Visibility", tag = "10")] - pub visibility: i32, - #[prost(int32, tag = "11")] - pub uid: i32, - #[prost(message, optional, tag = "12")] - pub compat: ::core::option::Option, + impl Scale { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.GraphicalFunction.Scale"; } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Aux { - #[prost(string, tag = "1")] - pub ident: ::prost::alloc::string::String, - #[prost(message, optional, tag = "6")] - pub equation: ::core::option::Option, - #[prost(string, tag = "3")] - pub documentation: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub units: ::prost::alloc::string::String, - #[prost(message, optional, tag = "5")] - pub gf: ::core::option::Option, - #[prost(bool, tag = "7")] - pub can_be_module_input: bool, - #[prost(enumeration = "Visibility", tag = "8")] - pub visibility: i32, - #[prost(int32, tag = "9")] - pub uid: i32, - #[prost(message, optional, tag = "10")] - pub compat: ::core::option::Option, + ::buffa::impl_default_instance!(Scale); + impl ::buffa::MessageName for Scale { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "GraphicalFunction.Scale"; + const FULL_NAME: &'static str = "project_io.GraphicalFunction.Scale"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.GraphicalFunction.Scale"; } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Module { - #[prost(string, tag = "1")] - pub ident: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub model_name: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub documentation: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub units: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "5")] - pub references: ::prost::alloc::vec::Vec, - #[prost(bool, tag = "6")] - pub can_be_module_input: bool, - #[prost(enumeration = "Visibility", tag = "7")] - pub visibility: i32, - #[prost(int32, tag = "8")] - pub uid: i32, - #[prost(message, optional, tag = "9")] - pub compat: ::core::option::Option, + impl ::buffa::Message for Scale { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.min.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.max.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.min.to_bits() != 0u64 { + ::buffa::types::put_double_field(1u32, self.min, buf); + } + if self.max.to_bits() != 0u64 { + ::buffa::types::put_double_field(2u32, self.max, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.min = ::buffa::types::decode_double(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.max = ::buffa::types::decode_double(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.min = 0f64; + self.max = 0f64; + } } - /// Nested message and enum types in `Module`. - pub mod module { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct Reference { - #[prost(string, tag = "1")] - pub src: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub dst: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Default)] +pub struct Variable { + pub v: ::core::option::Option<__buffa::oneof::variable::V>, +} +impl ::core::fmt::Debug for Variable { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Variable").field("v", &self.v).finish() + } +} +impl Variable { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable"; +} +::buffa::impl_default_instance!(Variable); +impl ::buffa::MessageName for Variable { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable"; + const FULL_NAME: &'static str = "project_io.Variable"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable"; +} +impl ::buffa::Message for Variable { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.v { + match v { + __buffa::oneof::variable::V::Stock(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::variable::V::Flow(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::variable::V::Aux(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::variable::V::Module(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.v { + match v { + __buffa::oneof::variable::V::Stock(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::variable::V::Flow(x) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::variable::V::Aux(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::variable::V::Module(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::variable::V::Stock( + ref mut existing, + )) = self.v + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.v = ::core::option::Option::Some(__buffa::oneof::variable::V::Stock(val)); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::variable::V::Flow( + ref mut existing, + )) = self.v + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.v = ::core::option::Option::Some(__buffa::oneof::variable::V::Flow(val)); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::variable::V::Aux( + ref mut existing, + )) = self.v + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.v = ::core::option::Option::Some(__buffa::oneof::variable::V::Aux(val)); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::variable::V::Module( + ref mut existing, + )) = self.v + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.v = ::core::option::Option::Some(__buffa::oneof::variable::V::Module(val)); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.v = ::core::option::Option::None; } +} +pub mod variable { + #[allow(unused_imports)] + use super::*; /// access=output XMILE variables have public access, all others are private. - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] #[repr(i32)] pub enum Visibility { - Private = 0, - Public = 1, + PRIVATE = 0i32, + PUBLIC = 1i32, } impl Visibility { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { + ///Idiomatic alias for [`Self::PRIVATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Private: Self = Self::PRIVATE; + ///Idiomatic alias for [`Self::PUBLIC`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Public: Self = Self::PUBLIC; + } + impl ::core::default::Default for Visibility { + fn default() -> Self { + Self::PRIVATE + } + } + impl ::buffa::Enumeration for Visibility { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::PRIVATE), + 1i32 => ::core::option::Option::Some(Self::PUBLIC), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { match self { - Self::Private => "PRIVATE", - Self::Public => "PUBLIC", + Self::PRIVATE => "PRIVATE", + Self::PUBLIC => "PUBLIC", } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "PRIVATE" => Some(Self::Private), - "PUBLIC" => Some(Self::Public), - _ => None, + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "PRIVATE" => ::core::option::Option::Some(Self::PRIVATE), + "PUBLIC" => ::core::option::Option::Some(Self::PUBLIC), + _ => ::core::option::Option::None, } } + fn values() -> &'static [Self] { + &[Self::PRIVATE, Self::PUBLIC] + } } - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum V { - #[prost(message, tag = "1")] - Stock(Stock), - #[prost(message, tag = "2")] - Flow(Flow), - #[prost(message, tag = "3")] - Aux(Aux), - #[prost(message, tag = "4")] - Module(Module), - } -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ViewElement { - #[prost(oneof = "view_element::Element", tags = "1, 2, 3, 4, 5, 6, 7, 8")] - pub element: ::core::option::Option, -} -/// Nested message and enum types in `ViewElement`. -pub mod view_element { - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct ViewElementCompat { - #[prost(double, optional, tag = "1")] - pub width: ::core::option::Option, - #[prost(double, optional, tag = "2")] - pub height: ::core::option::Option, - #[prost(uint32, optional, tag = "3")] - pub bits: ::core::option::Option, - } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Aux { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub uid: i32, - #[prost(double, tag = "3")] - pub x: f64, - #[prost(double, tag = "4")] - pub y: f64, - #[prost(enumeration = "LabelSide", tag = "5")] - pub label_side: i32, - #[prost(message, optional, tag = "6")] - pub compat: ::core::option::Option, + #[derive(Clone, PartialEq, Default)] + pub struct ScalarEquation { + /// Field 1: `equation` + pub equation: ::buffa::alloc::string::String, + /// Field 2: `initial_equation` + pub initial_equation: ::core::option::Option<::buffa::alloc::string::String>, } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Stock { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub uid: i32, - #[prost(double, tag = "3")] - pub x: f64, - #[prost(double, tag = "4")] - pub y: f64, - #[prost(enumeration = "LabelSide", tag = "5")] - pub label_side: i32, - #[prost(message, optional, tag = "6")] - pub compat: ::core::option::Option, + impl ::core::fmt::Debug for ScalarEquation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ScalarEquation") + .field("equation", &self.equation) + .field("initial_equation", &self.initial_equation) + .finish() + } } - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct FlowPoint { - #[prost(double, tag = "1")] - pub x: f64, - #[prost(double, tag = "2")] - pub y: f64, - #[prost(int32, tag = "3")] - pub attached_to_uid: i32, + impl ScalarEquation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.ScalarEquation"; } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Flow { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub uid: i32, - #[prost(double, tag = "3")] - pub x: f64, - #[prost(double, tag = "4")] - pub y: f64, - #[prost(enumeration = "LabelSide", tag = "5")] - pub label_side: i32, - /// int32 segmentWithAux = 3; - /// double auxPercentageIntoSegment = 4; - #[prost(message, repeated, tag = "6")] - pub points: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "7")] - pub compat: ::core::option::Option, - #[prost(message, optional, tag = "8")] - pub label_compat: ::core::option::Option, - } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Link { - #[prost(int32, tag = "1")] - pub uid: i32, - #[prost(int32, tag = "2")] - pub from_uid: i32, - #[prost(int32, tag = "3")] - pub to_uid: i32, - #[prost(enumeration = "link::Polarity", tag = "7")] - pub polarity: i32, - #[prost(oneof = "link::Shape", tags = "4, 5, 6")] - pub shape: ::core::option::Option, + ::buffa::impl_default_instance!(ScalarEquation); + impl ::buffa::MessageName for ScalarEquation { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.ScalarEquation"; + const FULL_NAME: &'static str = "project_io.Variable.ScalarEquation"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.ScalarEquation"; } - /// Nested message and enum types in `Link`. - pub mod link { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct LinkPoints { - #[prost(message, repeated, tag = "1")] - pub points: ::prost::alloc::vec::Vec, + impl ::buffa::Message for ScalarEquation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.equation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.equation) as u64; + } + if let Some(ref v) = self.initial_equation { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) } - #[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, - )] - #[repr(i32)] - pub enum Polarity { - Unspecified = 0, - Positive = 1, - Negative = 2, + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.equation.is_empty() { + ::buffa::types::put_string_field(1u32, &self.equation, buf); + } + if let Some(ref v) = self.initial_equation { + ::buffa::types::put_string_field(2u32, v, buf); + } } - impl Polarity { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "POLARITY_UNSPECIFIED", - Self::Positive => "POLARITY_POSITIVE", - Self::Negative => "POLARITY_NEGATIVE", + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.equation, buf)?; } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "POLARITY_UNSPECIFIED" => Some(Self::Unspecified), - "POLARITY_POSITIVE" => Some(Self::Positive), - "POLARITY_NEGATIVE" => Some(Self::Negative), - _ => None, + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.initial_equation + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; } } + ::core::result::Result::Ok(()) } - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Shape { - /// [0, 360) - #[prost(double, tag = "4")] - Arc(f64), - #[prost(bool, tag = "5")] - IsStraight(bool), - #[prost(message, tag = "6")] - MultiPoint(LinkPoints), + fn clear(&mut self) { + self.equation.clear(); + self.initial_equation = ::core::option::Option::None; } } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Module { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub uid: i32, - #[prost(double, tag = "3")] - pub x: f64, - #[prost(double, tag = "4")] - pub y: f64, - #[prost(enumeration = "LabelSide", tag = "5")] - pub label_side: i32, + #[derive(Clone, PartialEq, Default)] + pub struct ApplyToAllEquation { + /// Field 1: `dimension_names` + pub dimension_names: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 2: `equation` + pub equation: ::buffa::alloc::string::String, + /// Field 3: `initial_equation` + pub initial_equation: ::core::option::Option<::buffa::alloc::string::String>, } - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct Alias { - #[prost(int32, tag = "1")] - pub uid: i32, - #[prost(int32, tag = "2")] - pub alias_of_uid: i32, - #[prost(double, tag = "3")] - pub x: f64, - #[prost(double, tag = "4")] - pub y: f64, - #[prost(enumeration = "LabelSide", tag = "5")] - pub label_side: i32, - #[prost(message, optional, tag = "6")] - pub compat: ::core::option::Option, + impl ::core::fmt::Debug for ApplyToAllEquation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ApplyToAllEquation") + .field("dimension_names", &self.dimension_names) + .field("equation", &self.equation) + .field("initial_equation", &self.initial_equation) + .finish() + } } - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct Cloud { - #[prost(int32, tag = "1")] - pub uid: i32, - #[prost(int32, tag = "2")] - pub flow_uid: i32, - #[prost(double, tag = "3")] + impl ApplyToAllEquation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Variable.ApplyToAllEquation"; + } + ::buffa::impl_default_instance!(ApplyToAllEquation); + impl ::buffa::MessageName for ApplyToAllEquation { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.ApplyToAllEquation"; + const FULL_NAME: &'static str = "project_io.Variable.ApplyToAllEquation"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.ApplyToAllEquation"; + } + impl ::buffa::Message for ApplyToAllEquation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.dimension_names { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if !self.equation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.equation) as u64; + } + if let Some(ref v) = self.initial_equation { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.dimension_names { + ::buffa::types::put_string_field(1u32, v, buf); + } + if !self.equation.is_empty() { + ::buffa::types::put_string_field(2u32, &self.equation, buf); + } + if let Some(ref v) = self.initial_equation { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.dimension_names.push(__elem); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.equation, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.initial_equation + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.dimension_names.clear(); + self.equation.clear(); + self.initial_equation = ::core::option::Option::None; + } + } + #[derive(Clone, PartialEq, Default)] + pub struct ArrayedEquation { + /// Field 1: `dimension_names` + pub dimension_names: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 2: `elements` + pub elements: ::buffa::alloc::vec::Vec, + /// Field 3: `has_except_default` + pub has_except_default: ::core::option::Option, + /// Field 4: `default_equation` + pub default_equation: ::core::option::Option<::buffa::alloc::string::String>, + } + impl ::core::fmt::Debug for ArrayedEquation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ArrayedEquation") + .field("dimension_names", &self.dimension_names) + .field("elements", &self.elements) + .field("has_except_default", &self.has_except_default) + .field("default_equation", &self.default_equation) + .finish() + } + } + impl ArrayedEquation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Variable.ArrayedEquation"; + } + ::buffa::impl_default_instance!(ArrayedEquation); + impl ::buffa::MessageName for ArrayedEquation { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.ArrayedEquation"; + const FULL_NAME: &'static str = "project_io.Variable.ArrayedEquation"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.ArrayedEquation"; + } + impl ::buffa::Message for ArrayedEquation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.dimension_names { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.elements { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.has_except_default.is_some() { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if let Some(ref v) = self.default_equation { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.dimension_names { + ::buffa::types::put_string_field(1u32, v, buf); + } + for v in &self.elements { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(v) = self.has_except_default { + ::buffa::types::put_bool_field(3u32, v, buf); + } + if let Some(ref v) = self.default_equation { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.dimension_names.push(__elem); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.elements.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.has_except_default = + ::core::option::Option::Some(::buffa::types::decode_bool(buf)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.default_equation + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.dimension_names.clear(); + self.elements.clear(); + self.has_except_default = ::core::option::Option::None; + self.default_equation = ::core::option::Option::None; + } + } + pub mod arrayed_equation { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + pub struct Element { + /// Field 1: `subscript` + pub subscript: ::buffa::alloc::string::String, + /// Field 2: `equation` + pub equation: ::buffa::alloc::string::String, + /// Field 3: `initial_equation` + pub initial_equation: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 4: `gf` + pub gf: ::buffa::MessageField< + super::super::GraphicalFunction, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Element { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Element") + .field("subscript", &self.subscript) + .field("equation", &self.equation) + .field("initial_equation", &self.initial_equation) + .field("gf", &self.gf) + .finish() + } + } + impl Element { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Variable.ArrayedEquation.Element"; + } + ::buffa::impl_default_instance!(Element); + impl ::buffa::MessageName for Element { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.ArrayedEquation.Element"; + const FULL_NAME: &'static str = "project_io.Variable.ArrayedEquation.Element"; + const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Variable.ArrayedEquation.Element"; + } + impl ::buffa::Message for Element { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.subscript.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.subscript) as u64; + } + if !self.equation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.equation) as u64; + } + if let Some(ref v) = self.initial_equation { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.gf.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.gf.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.subscript.is_empty() { + ::buffa::types::put_string_field(1u32, &self.subscript, buf); + } + if !self.equation.is_empty() { + ::buffa::types::put_string_field(2u32, &self.equation, buf); + } + if let Some(ref v) = self.initial_equation { + ::buffa::types::put_string_field(3u32, v, buf); + } + if self.gf.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.gf.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.subscript, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.equation, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.initial_equation + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.gf.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.subscript.clear(); + self.equation.clear(); + self.initial_equation = ::core::option::Option::None; + self.gf = ::buffa::MessageField::none(); + } + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Equation { + pub equation: ::core::option::Option, + } + impl ::core::fmt::Debug for Equation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Equation") + .field("equation", &self.equation) + .finish() + } + } + impl Equation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Equation"; + } + ::buffa::impl_default_instance!(Equation); + impl ::buffa::MessageName for Equation { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Equation"; + const FULL_NAME: &'static str = "project_io.Variable.Equation"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Equation"; + } + impl ::buffa::Message for Equation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.equation { + match v { + super::__buffa::oneof::variable::equation::Equation::Scalar(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += 1u64 + + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::__buffa::oneof::variable::equation::Equation::ApplyToAll(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += 1u64 + + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::__buffa::oneof::variable::equation::Equation::Arrayed(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += 1u64 + + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.equation { + match v { + super::__buffa::oneof::variable::equation::Equation::Scalar(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::variable::equation::Equation::ApplyToAll(x) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::variable::equation::Equation::Arrayed(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + super::__buffa::oneof::variable::equation::Equation::Scalar( + ref mut existing, + ), + ) = self.equation + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.equation = ::core::option::Option::Some( + super::__buffa::oneof::variable::equation::Equation::Scalar(val), + ); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + super::__buffa::oneof::variable::equation::Equation::ApplyToAll( + ref mut existing, + ), + ) = self.equation + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.equation = ::core::option::Option::Some( + super::__buffa::oneof::variable::equation::Equation::ApplyToAll(val), + ); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + super::__buffa::oneof::variable::equation::Equation::Arrayed( + ref mut existing, + ), + ) = self.equation + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.equation = ::core::option::Option::Some( + super::__buffa::oneof::variable::equation::Equation::Arrayed(val), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.equation = ::core::option::Option::None; + } + } + pub mod equation { + #[doc(inline)] + pub use super::super::__buffa::oneof::variable::equation::Equation; + #[allow(unused_imports)] + use super::*; + } + #[derive(Clone, PartialEq, Default)] + pub struct DataSource { + /// Field 1: `kind` + pub kind: ::buffa::EnumValue, + /// Field 2: `file` + pub file: ::buffa::alloc::string::String, + /// Field 3: `tab_or_delimiter` + pub tab_or_delimiter: ::buffa::alloc::string::String, + /// Field 4: `row_or_col` + pub row_or_col: ::buffa::alloc::string::String, + /// Field 5: `cell` + pub cell: ::buffa::alloc::string::String, + } + impl ::core::fmt::Debug for DataSource { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DataSource") + .field("kind", &self.kind) + .field("file", &self.file) + .field("tab_or_delimiter", &self.tab_or_delimiter) + .field("row_or_col", &self.row_or_col) + .field("cell", &self.cell) + .finish() + } + } + impl DataSource { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.DataSource"; + } + ::buffa::impl_default_instance!(DataSource); + impl ::buffa::MessageName for DataSource { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.DataSource"; + const FULL_NAME: &'static str = "project_io.Variable.DataSource"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.DataSource"; + } + impl ::buffa::Message for DataSource { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if !self.file.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.file) as u64; + } + if !self.tab_or_delimiter.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.tab_or_delimiter) as u64; + } + if !self.row_or_col.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.row_or_col) as u64; + } + if !self.cell.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.cell) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.kind.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(1u32, val, buf); + } + } + if !self.file.is_empty() { + ::buffa::types::put_string_field(2u32, &self.file, buf); + } + if !self.tab_or_delimiter.is_empty() { + ::buffa::types::put_string_field(3u32, &self.tab_or_delimiter, buf); + } + if !self.row_or_col.is_empty() { + ::buffa::types::put_string_field(4u32, &self.row_or_col, buf); + } + if !self.cell.is_empty() { + ::buffa::types::put_string_field(5u32, &self.cell, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.file, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tab_or_delimiter, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.row_or_col, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.cell, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.kind = ::buffa::EnumValue::from(0); + self.file.clear(); + self.tab_or_delimiter.clear(); + self.row_or_col.clear(); + self.cell.clear(); + } + } + pub mod data_source { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum Kind { + DATA = 0i32, + CONSTANTS = 1i32, + LOOKUPS = 2i32, + SUBSCRIPT = 3i32, + } + impl Kind { + ///Idiomatic alias for [`Self::DATA`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Data: Self = Self::DATA; + ///Idiomatic alias for [`Self::CONSTANTS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Constants: Self = Self::CONSTANTS; + ///Idiomatic alias for [`Self::LOOKUPS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Lookups: Self = Self::LOOKUPS; + ///Idiomatic alias for [`Self::SUBSCRIPT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Subscript: Self = Self::SUBSCRIPT; + } + impl ::core::default::Default for Kind { + fn default() -> Self { + Self::DATA + } + } + impl ::buffa::Enumeration for Kind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::DATA), + 1i32 => ::core::option::Option::Some(Self::CONSTANTS), + 2i32 => ::core::option::Option::Some(Self::LOOKUPS), + 3i32 => ::core::option::Option::Some(Self::SUBSCRIPT), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::DATA => "DATA", + Self::CONSTANTS => "CONSTANTS", + Self::LOOKUPS => "LOOKUPS", + Self::SUBSCRIPT => "SUBSCRIPT", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "DATA" => ::core::option::Option::Some(Self::DATA), + "CONSTANTS" => ::core::option::Option::Some(Self::CONSTANTS), + "LOOKUPS" => ::core::option::Option::Some(Self::LOOKUPS), + "SUBSCRIPT" => ::core::option::Option::Some(Self::SUBSCRIPT), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[Self::DATA, Self::CONSTANTS, Self::LOOKUPS, Self::SUBSCRIPT] + } + } + } + /// A conveyor stock's belt parameters. See docs/design/conveyors.md. + #[derive(Clone, PartialEq, Default)] + pub struct Conveyor { + /// \ (required) + /// + /// Field 1: `transit_time` + pub transit_time: ::buffa::alloc::string::String, + /// \ + /// + /// Field 2: `capacity` + pub capacity: ::core::option::Option<::buffa::alloc::string::String>, + /// \ + /// + /// Field 3: `inflow_limit` + pub inflow_limit: ::core::option::Option<::buffa::alloc::string::String>, + /// \ + /// + /// Field 4: `sample` + pub sample: ::core::option::Option<::buffa::alloc::string::String>, + /// \ + /// + /// Field 5: `arrest` + pub arrest: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 6: `discrete` + pub discrete: bool, + /// Field 7: `batch_integrity` + pub batch_integrity: bool, + /// default true + /// + /// Field 8: `one_at_a_time` + pub one_at_a_time: bool, + /// Field 9: `exponential_leak` + pub exponential_leak: bool, + /// Field 10: `ignore_earlier_zone_losses` + pub ignore_earlier_zone_losses: bool, + } + impl ::core::fmt::Debug for Conveyor { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Conveyor") + .field("transit_time", &self.transit_time) + .field("capacity", &self.capacity) + .field("inflow_limit", &self.inflow_limit) + .field("sample", &self.sample) + .field("arrest", &self.arrest) + .field("discrete", &self.discrete) + .field("batch_integrity", &self.batch_integrity) + .field("one_at_a_time", &self.one_at_a_time) + .field("exponential_leak", &self.exponential_leak) + .field( + "ignore_earlier_zone_losses", + &self.ignore_earlier_zone_losses, + ) + .finish() + } + } + impl Conveyor { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Conveyor"; + } + ::buffa::impl_default_instance!(Conveyor); + impl ::buffa::MessageName for Conveyor { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Conveyor"; + const FULL_NAME: &'static str = "project_io.Variable.Conveyor"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Conveyor"; + } + impl ::buffa::Message for Conveyor { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.transit_time.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.transit_time) as u64; + } + if let Some(ref v) = self.capacity { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.inflow_limit { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.sample { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.arrest { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.discrete { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.batch_integrity { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.one_at_a_time { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.exponential_leak { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.ignore_earlier_zone_losses { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.transit_time.is_empty() { + ::buffa::types::put_string_field(1u32, &self.transit_time, buf); + } + if let Some(ref v) = self.capacity { + ::buffa::types::put_string_field(2u32, v, buf); + } + if let Some(ref v) = self.inflow_limit { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.sample { + ::buffa::types::put_string_field(4u32, v, buf); + } + if let Some(ref v) = self.arrest { + ::buffa::types::put_string_field(5u32, v, buf); + } + if self.discrete { + ::buffa::types::put_bool_field(6u32, self.discrete, buf); + } + if self.batch_integrity { + ::buffa::types::put_bool_field(7u32, self.batch_integrity, buf); + } + if self.one_at_a_time { + ::buffa::types::put_bool_field(8u32, self.one_at_a_time, buf); + } + if self.exponential_leak { + ::buffa::types::put_bool_field(9u32, self.exponential_leak, buf); + } + if self.ignore_earlier_zone_losses { + ::buffa::types::put_bool_field(10u32, self.ignore_earlier_zone_losses, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.transit_time, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.capacity + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.inflow_limit + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.sample + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.arrest + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.discrete = ::buffa::types::decode_bool(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.batch_integrity = ::buffa::types::decode_bool(buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.one_at_a_time = ::buffa::types::decode_bool(buf)?; + } + 9u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.exponential_leak = ::buffa::types::decode_bool(buf)?; + } + 10u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.ignore_earlier_zone_losses = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.transit_time.clear(); + self.capacity = ::core::option::Option::None; + self.inflow_limit = ::core::option::Option::None; + self.sample = ::core::option::Option::None; + self.arrest = ::core::option::Option::None; + self.discrete = false; + self.batch_integrity = false; + self.one_at_a_time = false; + self.exponential_leak = false; + self.ignore_earlier_zone_losses = false; + } + } + /// Marks a flow as a conveyor leakage outflow. + #[derive(Clone, PartialEq, Default)] + pub struct Leakage { + /// None for a bare \ marker + /// + /// Field 1: `fraction` + pub fraction: ::core::option::Option<::buffa::alloc::string::String>, + /// \ + /// + /// Field 2: `integers` + pub integers: bool, + /// leak_start + /// + /// Field 3: `zone_start` + pub zone_start: ::core::option::Option<::buffa::alloc::string::String>, + /// leak_end + /// + /// Field 4: `zone_end` + pub zone_end: ::core::option::Option<::buffa::alloc::string::String>, + } + impl ::core::fmt::Debug for Leakage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Leakage") + .field("fraction", &self.fraction) + .field("integers", &self.integers) + .field("zone_start", &self.zone_start) + .field("zone_end", &self.zone_end) + .finish() + } + } + impl Leakage { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Leakage"; + } + ::buffa::impl_default_instance!(Leakage); + impl ::buffa::MessageName for Leakage { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Leakage"; + const FULL_NAME: &'static str = "project_io.Variable.Leakage"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Leakage"; + } + impl ::buffa::Message for Leakage { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(ref v) = self.fraction { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.integers { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if let Some(ref v) = self.zone_start { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.zone_end { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(ref v) = self.fraction { + ::buffa::types::put_string_field(1u32, v, buf); + } + if self.integers { + ::buffa::types::put_bool_field(2u32, self.integers, buf); + } + if let Some(ref v) = self.zone_start { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.zone_end { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.fraction + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.integers = ::buffa::types::decode_bool(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.zone_start + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.zone_end + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.fraction = ::core::option::Option::None; + self.integers = false; + self.zone_start = ::core::option::Option::None; + self.zone_end = ::core::option::Option::None; + } + } + /// isee:spreadflow inflow placement method. + #[derive(Clone, PartialEq, Default)] + pub struct SpreadFlow { + /// Field 1: `method` + pub method: ::buffa::EnumValue, + /// graphical-function name for DIST + /// + /// Field 2: `distrib_eq` + pub distrib_eq: ::core::option::Option<::buffa::alloc::string::String>, + } + impl ::core::fmt::Debug for SpreadFlow { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SpreadFlow") + .field("method", &self.method) + .field("distrib_eq", &self.distrib_eq) + .finish() + } + } + impl SpreadFlow { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.SpreadFlow"; + } + ::buffa::impl_default_instance!(SpreadFlow); + impl ::buffa::MessageName for SpreadFlow { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.SpreadFlow"; + const FULL_NAME: &'static str = "project_io.Variable.SpreadFlow"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.SpreadFlow"; + } + impl ::buffa::Message for SpreadFlow { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.method.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if let Some(ref v) = self.distrib_eq { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.method.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(1u32, val, buf); + } + } + if let Some(ref v) = self.distrib_eq { + ::buffa::types::put_string_field(2u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.method = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.distrib_eq + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.method = ::buffa::EnumValue::from(0); + self.distrib_eq = ::core::option::Option::None; + } + } + pub mod spread_flow { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum Method { + BEGINNING = 0i32, + EVEN = 1i32, + DEST = 2i32, + DIST = 3i32, + SOURCE = 4i32, + } + impl Method { + ///Idiomatic alias for [`Self::BEGINNING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Beginning: Self = Self::BEGINNING; + ///Idiomatic alias for [`Self::EVEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Even: Self = Self::EVEN; + ///Idiomatic alias for [`Self::DEST`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Dest: Self = Self::DEST; + ///Idiomatic alias for [`Self::DIST`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Dist: Self = Self::DIST; + ///Idiomatic alias for [`Self::SOURCE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Source: Self = Self::SOURCE; + } + impl ::core::default::Default for Method { + fn default() -> Self { + Self::BEGINNING + } + } + impl ::buffa::Enumeration for Method { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::BEGINNING), + 1i32 => ::core::option::Option::Some(Self::EVEN), + 2i32 => ::core::option::Option::Some(Self::DEST), + 3i32 => ::core::option::Option::Some(Self::DIST), + 4i32 => ::core::option::Option::Some(Self::SOURCE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::BEGINNING => "BEGINNING", + Self::EVEN => "EVEN", + Self::DEST => "DEST", + Self::DIST => "DIST", + Self::SOURCE => "SOURCE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "BEGINNING" => ::core::option::Option::Some(Self::BEGINNING), + "EVEN" => ::core::option::Option::Some(Self::EVEN), + "DEST" => ::core::option::Option::Some(Self::DEST), + "DIST" => ::core::option::Option::Some(Self::DIST), + "SOURCE" => ::core::option::Option::Some(Self::SOURCE), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::BEGINNING, + Self::EVEN, + Self::DEST, + Self::DIST, + Self::SOURCE, + ] + } + } + } + /// A queue stock has no options (XMILE §4.2). See docs/design/queues.md. + #[derive(Clone, PartialEq, Default)] + pub struct Queue {} + impl ::core::fmt::Debug for Queue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Queue").finish() + } + } + impl Queue { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Queue"; + } + ::buffa::impl_default_instance!(Queue); + impl ::buffa::MessageName for Queue { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Queue"; + const FULL_NAME: &'static str = "project_io.Variable.Queue"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Queue"; + } + impl ::buffa::Message for Queue { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u64; + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, _buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} + } + #[derive(Clone, PartialEq, Default)] + pub struct Compat { + /// Field 1: `active_initial` + pub active_initial: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 2: `non_negative` + pub non_negative: ::core::option::Option, + /// Field 3: `can_be_module_input` + pub can_be_module_input: ::core::option::Option, + /// Field 4: `visibility` + pub visibility: ::core::option::Option<::buffa::EnumValue>, + /// Field 5: `data_source` + pub data_source: ::buffa::MessageField< + super::variable::DataSource, + ::buffa::Inline, + >, + /// Field 6: `conveyor` + pub conveyor: ::buffa::MessageField< + super::variable::Conveyor, + ::buffa::Inline, + >, + /// Field 7: `leakage` + pub leakage: ::buffa::MessageField< + super::variable::Leakage, + ::buffa::Inline, + >, + /// Field 8: `spreadflow` + pub spreadflow: ::buffa::MessageField< + super::variable::SpreadFlow, + ::buffa::Inline, + >, + /// present iff a queue stock (\) + /// + /// Field 9: `queue` + pub queue: + ::buffa::MessageField>, + /// \ on a queue outflow + /// + /// Field 10: `overflow` + pub overflow: bool, + } + impl ::core::fmt::Debug for Compat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Compat") + .field("active_initial", &self.active_initial) + .field("non_negative", &self.non_negative) + .field("can_be_module_input", &self.can_be_module_input) + .field("visibility", &self.visibility) + .field("data_source", &self.data_source) + .field("conveyor", &self.conveyor) + .field("leakage", &self.leakage) + .field("spreadflow", &self.spreadflow) + .field("queue", &self.queue) + .field("overflow", &self.overflow) + .finish() + } + } + impl Compat { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Compat"; + } + ::buffa::impl_default_instance!(Compat); + impl ::buffa::MessageName for Compat { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Compat"; + const FULL_NAME: &'static str = "project_io.Variable.Compat"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Compat"; + } + impl ::buffa::Message for Compat { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(ref v) = self.active_initial { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.non_negative.is_some() { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.can_be_module_input.is_some() { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if let Some(ref v) = self.visibility { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if self.data_source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.data_source.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.conveyor.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.conveyor.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.leakage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.leakage.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.spreadflow.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.spreadflow.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.queue.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.queue.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.overflow { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(ref v) = self.active_initial { + ::buffa::types::put_string_field(1u32, v, buf); + } + if let Some(v) = self.non_negative { + ::buffa::types::put_bool_field(2u32, v, buf); + } + if let Some(v) = self.can_be_module_input { + ::buffa::types::put_bool_field(3u32, v, buf); + } + if let Some(ref v) = self.visibility { + ::buffa::types::put_int32_field(4u32, v.to_i32(), buf); + } + if self.data_source.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.data_source.write_to(__cache, buf); + } + if self.conveyor.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.conveyor.write_to(__cache, buf); + } + if self.leakage.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.leakage.write_to(__cache, buf); + } + if self.spreadflow.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.spreadflow.write_to(__cache, buf); + } + if self.queue.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.queue.write_to(__cache, buf); + } + if self.overflow { + ::buffa::types::put_bool_field(10u32, self.overflow, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.active_initial + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.non_negative = + ::core::option::Option::Some(::buffa::types::decode_bool(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.can_be_module_input = + ::core::option::Option::Some(::buffa::types::decode_bool(buf)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.visibility = ::core::option::Option::Some(::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + )); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.data_source.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.conveyor.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.leakage.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.spreadflow.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.queue.get_or_insert_default(), + buf, + ctx, + )?; + } + 10u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.overflow = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.active_initial = ::core::option::Option::None; + self.non_negative = ::core::option::Option::None; + self.can_be_module_input = ::core::option::Option::None; + self.visibility = ::core::option::Option::None; + self.data_source = ::buffa::MessageField::none(); + self.conveyor = ::buffa::MessageField::none(); + self.leakage = ::buffa::MessageField::none(); + self.spreadflow = ::buffa::MessageField::none(); + self.queue = ::buffa::MessageField::none(); + self.overflow = false; + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Stock { + /// Field 1: `ident` + pub ident: ::buffa::alloc::string::String, + /// Field 8: `equation` + pub equation: ::buffa::MessageField< + super::variable::Equation, + ::buffa::Inline, + >, + /// Field 3: `documentation` + pub documentation: ::buffa::alloc::string::String, + /// Field 4: `units` + pub units: ::buffa::alloc::string::String, + /// Field 5: `inflows` + pub inflows: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 6: `outflows` + pub outflows: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 7: `non_negative` + pub non_negative: bool, + /// Field 9: `can_be_module_input` + pub can_be_module_input: bool, + /// Field 10: `visibility` + pub visibility: ::buffa::EnumValue, + /// Field 11: `uid` + pub uid: i32, + /// Field 12: `compat` + pub compat: ::buffa::MessageField< + super::variable::Compat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Stock { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Stock") + .field("ident", &self.ident) + .field("equation", &self.equation) + .field("documentation", &self.documentation) + .field("units", &self.units) + .field("inflows", &self.inflows) + .field("outflows", &self.outflows) + .field("non_negative", &self.non_negative) + .field("can_be_module_input", &self.can_be_module_input) + .field("visibility", &self.visibility) + .field("uid", &self.uid) + .field("compat", &self.compat) + .finish() + } + } + impl Stock { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Stock"; + } + ::buffa::impl_default_instance!(Stock); + impl ::buffa::MessageName for Stock { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Stock"; + const FULL_NAME: &'static str = "project_io.Variable.Stock"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Stock"; + } + impl ::buffa::Message for Stock { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.ident.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.ident) as u64; + } + if !self.documentation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.documentation) as u64; + } + if !self.units.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.units) as u64; + } + for v in &self.inflows { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.outflows { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.non_negative { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.equation.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.equation.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.can_be_module_input { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + { + let val = self.visibility.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.ident.is_empty() { + ::buffa::types::put_string_field(1u32, &self.ident, buf); + } + if !self.documentation.is_empty() { + ::buffa::types::put_string_field(3u32, &self.documentation, buf); + } + if !self.units.is_empty() { + ::buffa::types::put_string_field(4u32, &self.units, buf); + } + for v in &self.inflows { + ::buffa::types::put_string_field(5u32, v, buf); + } + for v in &self.outflows { + ::buffa::types::put_string_field(6u32, v, buf); + } + if self.non_negative { + ::buffa::types::put_bool_field(7u32, self.non_negative, buf); + } + if self.equation.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.equation.write_to(__cache, buf); + } + if self.can_be_module_input { + ::buffa::types::put_bool_field(9u32, self.can_be_module_input, buf); + } + { + let val = self.visibility.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(10u32, val, buf); + } + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(11u32, self.uid, buf); + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ident, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.documentation, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.units, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.inflows.push(__elem); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.outflows.push(__elem); + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.non_negative = ::buffa::types::decode_bool(buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.equation.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.can_be_module_input = ::buffa::types::decode_bool(buf)?; + } + 10u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.visibility = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 11u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ident.clear(); + self.documentation.clear(); + self.units.clear(); + self.inflows.clear(); + self.outflows.clear(); + self.non_negative = false; + self.equation = ::buffa::MessageField::none(); + self.can_be_module_input = false; + self.visibility = ::buffa::EnumValue::from(0); + self.uid = 0i32; + self.compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Flow { + /// Field 1: `ident` + pub ident: ::buffa::alloc::string::String, + /// Field 8: `equation` + pub equation: ::buffa::MessageField< + super::variable::Equation, + ::buffa::Inline, + >, + /// Field 3: `documentation` + pub documentation: ::buffa::alloc::string::String, + /// Field 4: `units` + pub units: ::buffa::alloc::string::String, + /// Field 5: `gf` + pub gf: ::buffa::MessageField< + super::GraphicalFunction, + ::buffa::Inline, + >, + /// Field 7: `non_negative` + pub non_negative: bool, + /// Field 9: `can_be_module_input` + pub can_be_module_input: bool, + /// Field 10: `visibility` + pub visibility: ::buffa::EnumValue, + /// Field 11: `uid` + pub uid: i32, + /// Field 12: `compat` + pub compat: ::buffa::MessageField< + super::variable::Compat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Flow { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Flow") + .field("ident", &self.ident) + .field("equation", &self.equation) + .field("documentation", &self.documentation) + .field("units", &self.units) + .field("gf", &self.gf) + .field("non_negative", &self.non_negative) + .field("can_be_module_input", &self.can_be_module_input) + .field("visibility", &self.visibility) + .field("uid", &self.uid) + .field("compat", &self.compat) + .finish() + } + } + impl Flow { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Flow"; + } + ::buffa::impl_default_instance!(Flow); + impl ::buffa::MessageName for Flow { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Flow"; + const FULL_NAME: &'static str = "project_io.Variable.Flow"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Flow"; + } + impl ::buffa::Message for Flow { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.ident.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.ident) as u64; + } + if !self.documentation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.documentation) as u64; + } + if !self.units.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.units) as u64; + } + if self.gf.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.gf.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.non_negative { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if self.equation.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.equation.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.can_be_module_input { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + { + let val = self.visibility.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.ident.is_empty() { + ::buffa::types::put_string_field(1u32, &self.ident, buf); + } + if !self.documentation.is_empty() { + ::buffa::types::put_string_field(3u32, &self.documentation, buf); + } + if !self.units.is_empty() { + ::buffa::types::put_string_field(4u32, &self.units, buf); + } + if self.gf.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.gf.write_to(__cache, buf); + } + if self.non_negative { + ::buffa::types::put_bool_field(7u32, self.non_negative, buf); + } + if self.equation.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.equation.write_to(__cache, buf); + } + if self.can_be_module_input { + ::buffa::types::put_bool_field(9u32, self.can_be_module_input, buf); + } + { + let val = self.visibility.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(10u32, val, buf); + } + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(11u32, self.uid, buf); + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ident, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.documentation, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.units, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.gf.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.non_negative = ::buffa::types::decode_bool(buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.equation.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.can_be_module_input = ::buffa::types::decode_bool(buf)?; + } + 10u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.visibility = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 11u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ident.clear(); + self.documentation.clear(); + self.units.clear(); + self.gf = ::buffa::MessageField::none(); + self.non_negative = false; + self.equation = ::buffa::MessageField::none(); + self.can_be_module_input = false; + self.visibility = ::buffa::EnumValue::from(0); + self.uid = 0i32; + self.compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Aux { + /// Field 1: `ident` + pub ident: ::buffa::alloc::string::String, + /// Field 6: `equation` + pub equation: ::buffa::MessageField< + super::variable::Equation, + ::buffa::Inline, + >, + /// Field 3: `documentation` + pub documentation: ::buffa::alloc::string::String, + /// Field 4: `units` + pub units: ::buffa::alloc::string::String, + /// Field 5: `gf` + pub gf: ::buffa::MessageField< + super::GraphicalFunction, + ::buffa::Inline, + >, + /// Field 7: `can_be_module_input` + pub can_be_module_input: bool, + /// Field 8: `visibility` + pub visibility: ::buffa::EnumValue, + /// Field 9: `uid` + pub uid: i32, + /// Field 10: `compat` + pub compat: ::buffa::MessageField< + super::variable::Compat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Aux { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Aux") + .field("ident", &self.ident) + .field("equation", &self.equation) + .field("documentation", &self.documentation) + .field("units", &self.units) + .field("gf", &self.gf) + .field("can_be_module_input", &self.can_be_module_input) + .field("visibility", &self.visibility) + .field("uid", &self.uid) + .field("compat", &self.compat) + .finish() + } + } + impl Aux { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Aux"; + } + ::buffa::impl_default_instance!(Aux); + impl ::buffa::MessageName for Aux { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Aux"; + const FULL_NAME: &'static str = "project_io.Variable.Aux"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Aux"; + } + impl ::buffa::Message for Aux { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.ident.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.ident) as u64; + } + if !self.documentation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.documentation) as u64; + } + if !self.units.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.units) as u64; + } + if self.gf.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.gf.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.equation.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.equation.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.can_be_module_input { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + { + let val = self.visibility.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.ident.is_empty() { + ::buffa::types::put_string_field(1u32, &self.ident, buf); + } + if !self.documentation.is_empty() { + ::buffa::types::put_string_field(3u32, &self.documentation, buf); + } + if !self.units.is_empty() { + ::buffa::types::put_string_field(4u32, &self.units, buf); + } + if self.gf.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.gf.write_to(__cache, buf); + } + if self.equation.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.equation.write_to(__cache, buf); + } + if self.can_be_module_input { + ::buffa::types::put_bool_field(7u32, self.can_be_module_input, buf); + } + { + let val = self.visibility.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(8u32, val, buf); + } + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(9u32, self.uid, buf); + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ident, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.documentation, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.units, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.gf.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.equation.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.can_be_module_input = ::buffa::types::decode_bool(buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.visibility = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 9u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ident.clear(); + self.documentation.clear(); + self.units.clear(); + self.gf = ::buffa::MessageField::none(); + self.equation = ::buffa::MessageField::none(); + self.can_be_module_input = false; + self.visibility = ::buffa::EnumValue::from(0); + self.uid = 0i32; + self.compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Module { + /// Field 1: `ident` + pub ident: ::buffa::alloc::string::String, + /// Field 2: `model_name` + pub model_name: ::buffa::alloc::string::String, + /// Field 3: `documentation` + pub documentation: ::buffa::alloc::string::String, + /// Field 4: `units` + pub units: ::buffa::alloc::string::String, + /// Field 5: `references` + pub references: ::buffa::alloc::vec::Vec, + /// Field 6: `can_be_module_input` + pub can_be_module_input: bool, + /// Field 7: `visibility` + pub visibility: ::buffa::EnumValue, + /// Field 8: `uid` + pub uid: i32, + /// Field 9: `compat` + pub compat: ::buffa::MessageField< + super::variable::Compat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Module { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Module") + .field("ident", &self.ident) + .field("model_name", &self.model_name) + .field("documentation", &self.documentation) + .field("units", &self.units) + .field("references", &self.references) + .field("can_be_module_input", &self.can_be_module_input) + .field("visibility", &self.visibility) + .field("uid", &self.uid) + .field("compat", &self.compat) + .finish() + } + } + impl Module { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Module"; + } + ::buffa::impl_default_instance!(Module); + impl ::buffa::MessageName for Module { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Module"; + const FULL_NAME: &'static str = "project_io.Variable.Module"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Variable.Module"; + } + impl ::buffa::Message for Module { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.ident.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.ident) as u64; + } + if !self.model_name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.model_name) as u64; + } + if !self.documentation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.documentation) as u64; + } + if !self.units.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.units) as u64; + } + for v in &self.references { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.can_be_module_input { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + { + let val = self.visibility.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.ident.is_empty() { + ::buffa::types::put_string_field(1u32, &self.ident, buf); + } + if !self.model_name.is_empty() { + ::buffa::types::put_string_field(2u32, &self.model_name, buf); + } + if !self.documentation.is_empty() { + ::buffa::types::put_string_field(3u32, &self.documentation, buf); + } + if !self.units.is_empty() { + ::buffa::types::put_string_field(4u32, &self.units, buf); + } + for v in &self.references { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.can_be_module_input { + ::buffa::types::put_bool_field(6u32, self.can_be_module_input, buf); + } + { + let val = self.visibility.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(7u32, val, buf); + } + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(8u32, self.uid, buf); + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ident, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.model_name, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.documentation, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.units, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.references.push(elem); + } + 6u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.can_be_module_input = ::buffa::types::decode_bool(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.visibility = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 8u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ident.clear(); + self.model_name.clear(); + self.documentation.clear(); + self.units.clear(); + self.references.clear(); + self.can_be_module_input = false; + self.visibility = ::buffa::EnumValue::from(0); + self.uid = 0i32; + self.compat = ::buffa::MessageField::none(); + } + } + pub mod module { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + pub struct Reference { + /// Field 1: `src` + pub src: ::buffa::alloc::string::String, + /// Field 2: `dst` + pub dst: ::buffa::alloc::string::String, + } + impl ::core::fmt::Debug for Reference { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Reference") + .field("src", &self.src) + .field("dst", &self.dst) + .finish() + } + } + impl Reference { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Variable.Module.Reference"; + } + ::buffa::impl_default_instance!(Reference); + impl ::buffa::MessageName for Reference { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Variable.Module.Reference"; + const FULL_NAME: &'static str = "project_io.Variable.Module.Reference"; + const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Variable.Module.Reference"; + } + impl ::buffa::Message for Reference { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.src.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.src) as u64; + } + if !self.dst.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.dst) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.src.is_empty() { + ::buffa::types::put_string_field(1u32, &self.src, buf); + } + if !self.dst.is_empty() { + ::buffa::types::put_string_field(2u32, &self.dst, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.src, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.dst, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + } + } + } + #[doc(inline)] + pub use super::__buffa::oneof::variable::V; +} +#[derive(Clone, PartialEq, Default)] +pub struct ViewElement { + pub element: ::core::option::Option<__buffa::oneof::view_element::Element>, +} +impl ::core::fmt::Debug for ViewElement { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ViewElement") + .field("element", &self.element) + .finish() + } +} +impl ViewElement { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement"; +} +::buffa::impl_default_instance!(ViewElement); +impl ::buffa::MessageName for ViewElement { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement"; + const FULL_NAME: &'static str = "project_io.ViewElement"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement"; +} +impl ::buffa::Message for ViewElement { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.element { + match v { + __buffa::oneof::view_element::Element::Aux(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Stock(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Flow(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Link(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Module(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Alias(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Cloud(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::view_element::Element::Group(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.element { + match v { + __buffa::oneof::view_element::Element::Aux(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Stock(x) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Flow(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Link(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Module(x) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Alias(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Cloud(x) => { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::view_element::Element::Group(x) => { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Aux( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Aux(val), + ); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Stock( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Stock(val), + ); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Flow( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Flow(val), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Link( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Link(val), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Module(ref mut existing), + ) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Module(val), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Alias( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Alias(val), + ); + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Cloud( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Cloud(val), + ); + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::view_element::Element::Group( + ref mut existing, + )) = self.element + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.element = ::core::option::Option::Some( + __buffa::oneof::view_element::Element::Group(val), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.element = ::core::option::Option::None; + } +} +pub mod view_element { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum LabelSide { + TOP = 0i32, + LEFT = 1i32, + CENTER = 2i32, + BOTTOM = 3i32, + RIGHT = 4i32, + } + impl LabelSide { + ///Idiomatic alias for [`Self::TOP`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Top: Self = Self::TOP; + ///Idiomatic alias for [`Self::LEFT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Left: Self = Self::LEFT; + ///Idiomatic alias for [`Self::CENTER`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Center: Self = Self::CENTER; + ///Idiomatic alias for [`Self::BOTTOM`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Bottom: Self = Self::BOTTOM; + ///Idiomatic alias for [`Self::RIGHT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Right: Self = Self::RIGHT; + } + impl ::core::default::Default for LabelSide { + fn default() -> Self { + Self::TOP + } + } + impl ::buffa::Enumeration for LabelSide { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TOP), + 1i32 => ::core::option::Option::Some(Self::LEFT), + 2i32 => ::core::option::Option::Some(Self::CENTER), + 3i32 => ::core::option::Option::Some(Self::BOTTOM), + 4i32 => ::core::option::Option::Some(Self::RIGHT), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TOP => "TOP", + Self::LEFT => "LEFT", + Self::CENTER => "CENTER", + Self::BOTTOM => "BOTTOM", + Self::RIGHT => "RIGHT", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TOP" => ::core::option::Option::Some(Self::TOP), + "LEFT" => ::core::option::Option::Some(Self::LEFT), + "CENTER" => ::core::option::Option::Some(Self::CENTER), + "BOTTOM" => ::core::option::Option::Some(Self::BOTTOM), + "RIGHT" => ::core::option::Option::Some(Self::RIGHT), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TOP, + Self::LEFT, + Self::CENTER, + Self::BOTTOM, + Self::RIGHT, + ] + } + } + #[derive(Clone, PartialEq, Default)] + pub struct ViewElementCompat { + /// Field 1: `width` + pub width: ::core::option::Option, + /// Field 2: `height` + pub height: ::core::option::Option, + /// Field 3: `bits` + pub bits: ::core::option::Option, + } + impl ::core::fmt::Debug for ViewElementCompat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ViewElementCompat") + .field("width", &self.width) + .field("height", &self.height) + .field("bits", &self.bits) + .finish() + } + } + impl ViewElementCompat { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.ViewElement.ViewElementCompat"; + } + ::buffa::impl_default_instance!(ViewElementCompat); + impl ::buffa::MessageName for ViewElementCompat { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.ViewElementCompat"; + const FULL_NAME: &'static str = "project_io.ViewElement.ViewElementCompat"; + const TYPE_URL: &'static str = + "type.googleapis.com/project_io.ViewElement.ViewElementCompat"; + } + impl ::buffa::Message for ViewElementCompat { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.width.is_some() { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.height.is_some() { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if let Some(v) = self.bits { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.width { + ::buffa::types::put_double_field(1u32, v, buf); + } + if let Some(v) = self.height { + ::buffa::types::put_double_field(2u32, v, buf); + } + if let Some(v) = self.bits { + ::buffa::types::put_uint32_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.width = ::core::option::Option::Some(::buffa::types::decode_double(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.height = ::core::option::Option::Some(::buffa::types::decode_double(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.bits = ::core::option::Option::Some(::buffa::types::decode_uint32(buf)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.width = ::core::option::Option::None; + self.height = ::core::option::Option::None; + self.bits = ::core::option::Option::None; + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Aux { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `uid` + pub uid: i32, + /// Field 3: `x` + pub x: f64, + /// Field 4: `y` + pub y: f64, + /// Field 5: `label_side` + pub label_side: ::buffa::EnumValue, + /// Field 6: `compat` + pub compat: ::buffa::MessageField< + super::view_element::ViewElementCompat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Aux { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Aux") + .field("name", &self.name) + .field("uid", &self.uid) + .field("x", &self.x) + .field("y", &self.y) + .field("label_side", &self.label_side) + .field("compat", &self.compat) + .finish() + } + } + impl Aux { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Aux"; + } + ::buffa::impl_default_instance!(Aux); + impl ::buffa::MessageName for Aux { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Aux"; + const FULL_NAME: &'static str = "project_io.ViewElement.Aux"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Aux"; + } + impl ::buffa::Message for Aux { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + { + let val = self.label_side.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.uid, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + { + let val = self.label_side.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(5u32, val, buf); + } + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.label_side = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.uid = 0i32; + self.x = 0f64; + self.y = 0f64; + self.label_side = ::buffa::EnumValue::from(0); + self.compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Stock { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `uid` + pub uid: i32, + /// Field 3: `x` + pub x: f64, + /// Field 4: `y` + pub y: f64, + /// Field 5: `label_side` + pub label_side: ::buffa::EnumValue, + /// Field 6: `compat` + pub compat: ::buffa::MessageField< + super::view_element::ViewElementCompat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Stock { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Stock") + .field("name", &self.name) + .field("uid", &self.uid) + .field("x", &self.x) + .field("y", &self.y) + .field("label_side", &self.label_side) + .field("compat", &self.compat) + .finish() + } + } + impl Stock { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Stock"; + } + ::buffa::impl_default_instance!(Stock); + impl ::buffa::MessageName for Stock { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Stock"; + const FULL_NAME: &'static str = "project_io.ViewElement.Stock"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Stock"; + } + impl ::buffa::Message for Stock { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + { + let val = self.label_side.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.uid, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + { + let val = self.label_side.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(5u32, val, buf); + } + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.label_side = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.uid = 0i32; + self.x = 0f64; + self.y = 0f64; + self.label_side = ::buffa::EnumValue::from(0); + self.compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct FlowPoint { + /// Field 1: `x` + pub x: f64, + /// Field 2: `y` + pub y: f64, + /// Field 3: `attached_to_uid` + pub attached_to_uid: i32, + } + impl ::core::fmt::Debug for FlowPoint { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FlowPoint") + .field("x", &self.x) + .field("y", &self.y) + .field("attached_to_uid", &self.attached_to_uid) + .finish() + } + } + impl FlowPoint { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.FlowPoint"; + } + ::buffa::impl_default_instance!(FlowPoint); + impl ::buffa::MessageName for FlowPoint { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.FlowPoint"; + const FULL_NAME: &'static str = "project_io.ViewElement.FlowPoint"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.FlowPoint"; + } + impl ::buffa::Message for FlowPoint { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.attached_to_uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.attached_to_uid) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(1u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(2u32, self.y, buf); + } + if self.attached_to_uid != 0i32 { + ::buffa::types::put_int32_field(3u32, self.attached_to_uid, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.attached_to_uid = ::buffa::types::decode_int32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.x = 0f64; + self.y = 0f64; + self.attached_to_uid = 0i32; + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Flow { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `uid` + pub uid: i32, + /// Field 3: `x` + pub x: f64, + /// Field 4: `y` + pub y: f64, + /// Field 5: `label_side` + pub label_side: ::buffa::EnumValue, + /// int32 segmentWithAux = 3; + /// double auxPercentageIntoSegment = 4; + /// + /// Field 6: `points` + pub points: ::buffa::alloc::vec::Vec, + /// Field 7: `compat` + pub compat: ::buffa::MessageField< + super::view_element::ViewElementCompat, + ::buffa::Inline, + >, + /// Field 8: `label_compat` + pub label_compat: ::buffa::MessageField< + super::view_element::ViewElementCompat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Flow { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Flow") + .field("name", &self.name) + .field("uid", &self.uid) + .field("x", &self.x) + .field("y", &self.y) + .field("label_side", &self.label_side) + .field("points", &self.points) + .field("compat", &self.compat) + .field("label_compat", &self.label_compat) + .finish() + } + } + impl Flow { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Flow"; + } + ::buffa::impl_default_instance!(Flow); + impl ::buffa::MessageName for Flow { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Flow"; + const FULL_NAME: &'static str = "project_io.ViewElement.Flow"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Flow"; + } + impl ::buffa::Message for Flow { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + { + let val = self.label_side.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + for v in &self.points { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.label_compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.label_compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.uid, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + { + let val = self.label_side.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(5u32, val, buf); + } + } + for v in &self.points { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + if self.label_compat.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.label_compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.label_side = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.points.push(elem); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.label_compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.uid = 0i32; + self.x = 0f64; + self.y = 0f64; + self.label_side = ::buffa::EnumValue::from(0); + self.points.clear(); + self.compat = ::buffa::MessageField::none(); + self.label_compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Link { + /// Field 1: `uid` + pub uid: i32, + /// Field 2: `from_uid` + pub from_uid: i32, + /// Field 3: `to_uid` + pub to_uid: i32, + /// Field 7: `polarity` + pub polarity: ::buffa::EnumValue, + pub shape: ::core::option::Option, + } + impl ::core::fmt::Debug for Link { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Link") + .field("uid", &self.uid) + .field("from_uid", &self.from_uid) + .field("to_uid", &self.to_uid) + .field("polarity", &self.polarity) + .field("shape", &self.shape) + .finish() + } + } + impl Link { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Link"; + } + ::buffa::impl_default_instance!(Link); + impl ::buffa::MessageName for Link { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Link"; + const FULL_NAME: &'static str = "project_io.ViewElement.Link"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Link"; + } + impl ::buffa::Message for Link { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.from_uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.from_uid) as u64; + } + if self.to_uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.to_uid) as u64; + } + if let ::core::option::Option::Some(ref v) = self.shape { + match v { + super::__buffa::oneof::view_element::link::Shape::Arc(_x) => { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + super::__buffa::oneof::view_element::link::Shape::IsStraight(_x) => { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + super::__buffa::oneof::view_element::link::Shape::MultiPoint(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += 1u64 + + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + { + let val = self.polarity.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.uid != 0i32 { + ::buffa::types::put_int32_field(1u32, self.uid, buf); + } + if self.from_uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.from_uid, buf); + } + if self.to_uid != 0i32 { + ::buffa::types::put_int32_field(3u32, self.to_uid, buf); + } + if let ::core::option::Option::Some(ref v) = self.shape { + match v { + super::__buffa::oneof::view_element::link::Shape::Arc(x) => { + ::buffa::types::put_double_field(4u32, *x, buf); + } + super::__buffa::oneof::view_element::link::Shape::IsStraight(x) => { + ::buffa::types::put_bool_field(5u32, *x, buf); + } + super::__buffa::oneof::view_element::link::Shape::MultiPoint(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + { + let val = self.polarity.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(7u32, val, buf); + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.from_uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.to_uid = ::buffa::types::decode_int32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.shape = ::core::option::Option::Some( + super::__buffa::oneof::view_element::link::Shape::Arc( + ::buffa::types::decode_double(buf)?, + ), + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.shape = ::core::option::Option::Some( + super::__buffa::oneof::view_element::link::Shape::IsStraight( + ::buffa::types::decode_bool(buf)?, + ), + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + super::__buffa::oneof::view_element::link::Shape::MultiPoint( + ref mut existing, + ), + ) = self.shape + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.shape = ::core::option::Option::Some( + super::__buffa::oneof::view_element::link::Shape::MultiPoint(val), + ); + } + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.polarity = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.uid = 0i32; + self.from_uid = 0i32; + self.to_uid = 0i32; + self.shape = ::core::option::Option::None; + self.polarity = ::buffa::EnumValue::from(0); + } + } + pub mod link { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum Polarity { + POLARITY_UNSPECIFIED = 0i32, + POLARITY_POSITIVE = 1i32, + POLARITY_NEGATIVE = 2i32, + } + impl Polarity { + ///Idiomatic alias for [`Self::POLARITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::POLARITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::POLARITY_POSITIVE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Positive: Self = Self::POLARITY_POSITIVE; + ///Idiomatic alias for [`Self::POLARITY_NEGATIVE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Negative: Self = Self::POLARITY_NEGATIVE; + } + impl ::core::default::Default for Polarity { + fn default() -> Self { + Self::POLARITY_UNSPECIFIED + } + } + impl ::buffa::Enumeration for Polarity { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::POLARITY_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::POLARITY_POSITIVE), + 2i32 => ::core::option::Option::Some(Self::POLARITY_NEGATIVE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::POLARITY_UNSPECIFIED => "POLARITY_UNSPECIFIED", + Self::POLARITY_POSITIVE => "POLARITY_POSITIVE", + Self::POLARITY_NEGATIVE => "POLARITY_NEGATIVE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "POLARITY_UNSPECIFIED" => { + ::core::option::Option::Some(Self::POLARITY_UNSPECIFIED) + } + "POLARITY_POSITIVE" => ::core::option::Option::Some(Self::POLARITY_POSITIVE), + "POLARITY_NEGATIVE" => ::core::option::Option::Some(Self::POLARITY_NEGATIVE), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::POLARITY_UNSPECIFIED, + Self::POLARITY_POSITIVE, + Self::POLARITY_NEGATIVE, + ] + } + } + #[derive(Clone, PartialEq, Default)] + pub struct LinkPoints { + /// Field 1: `points` + pub points: ::buffa::alloc::vec::Vec, + } + impl ::core::fmt::Debug for LinkPoints { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("LinkPoints") + .field("points", &self.points) + .finish() + } + } + impl LinkPoints { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.ViewElement.Link.LinkPoints"; + } + ::buffa::impl_default_instance!(LinkPoints); + impl ::buffa::MessageName for LinkPoints { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Link.LinkPoints"; + const FULL_NAME: &'static str = "project_io.ViewElement.Link.LinkPoints"; + const TYPE_URL: &'static str = + "type.googleapis.com/project_io.ViewElement.Link.LinkPoints"; + } + impl ::buffa::Message for LinkPoints { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.points { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.points { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.points.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.points.clear(); + } + } + #[doc(inline)] + pub use super::super::__buffa::oneof::view_element::link::Shape; + } + #[derive(Clone, PartialEq, Default)] + pub struct Module { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `uid` + pub uid: i32, + /// Field 3: `x` + pub x: f64, + /// Field 4: `y` + pub y: f64, + /// Field 5: `label_side` + pub label_side: ::buffa::EnumValue, + } + impl ::core::fmt::Debug for Module { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Module") + .field("name", &self.name) + .field("uid", &self.uid) + .field("x", &self.x) + .field("y", &self.y) + .field("label_side", &self.label_side) + .finish() + } + } + impl Module { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Module"; + } + ::buffa::impl_default_instance!(Module); + impl ::buffa::MessageName for Module { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Module"; + const FULL_NAME: &'static str = "project_io.ViewElement.Module"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Module"; + } + impl ::buffa::Message for Module { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + { + let val = self.label_side.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if self.uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.uid, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + { + let val = self.label_side.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(5u32, val, buf); + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.label_side = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.uid = 0i32; + self.x = 0f64; + self.y = 0f64; + self.label_side = ::buffa::EnumValue::from(0); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Alias { + /// Field 1: `uid` + pub uid: i32, + /// Field 2: `alias_of_uid` + pub alias_of_uid: i32, + /// Field 3: `x` + pub x: f64, + /// Field 4: `y` + pub y: f64, + /// Field 5: `label_side` + pub label_side: ::buffa::EnumValue, + /// Field 6: `compat` + pub compat: ::buffa::MessageField< + super::view_element::ViewElementCompat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Alias { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Alias") + .field("uid", &self.uid) + .field("alias_of_uid", &self.alias_of_uid) + .field("x", &self.x) + .field("y", &self.y) + .field("label_side", &self.label_side) + .field("compat", &self.compat) + .finish() + } + } + impl Alias { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Alias"; + } + ::buffa::impl_default_instance!(Alias); + impl ::buffa::MessageName for Alias { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Alias"; + const FULL_NAME: &'static str = "project_io.ViewElement.Alias"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Alias"; + } + impl ::buffa::Message for Alias { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.alias_of_uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.alias_of_uid) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + { + let val = self.label_side.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.uid != 0i32 { + ::buffa::types::put_int32_field(1u32, self.uid, buf); + } + if self.alias_of_uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.alias_of_uid, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + { + let val = self.label_side.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(5u32, val, buf); + } + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.alias_of_uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.label_side = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.uid = 0i32; + self.alias_of_uid = 0i32; + self.x = 0f64; + self.y = 0f64; + self.label_side = ::buffa::EnumValue::from(0); + self.compat = ::buffa::MessageField::none(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct Cloud { + /// Field 1: `uid` + pub uid: i32, + /// Field 2: `flow_uid` + pub flow_uid: i32, + /// Field 3: `x` + pub x: f64, + /// Field 4: `y` + pub y: f64, + /// Field 5: `compat` + pub compat: ::buffa::MessageField< + super::view_element::ViewElementCompat, + ::buffa::Inline, + >, + } + impl ::core::fmt::Debug for Cloud { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Cloud") + .field("uid", &self.uid) + .field("flow_uid", &self.flow_uid) + .field("x", &self.x) + .field("y", &self.y) + .field("compat", &self.compat) + .finish() + } + } + impl Cloud { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Cloud"; + } + ::buffa::impl_default_instance!(Cloud); + impl ::buffa::MessageName for Cloud { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Cloud"; + const FULL_NAME: &'static str = "project_io.ViewElement.Cloud"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Cloud"; + } + impl ::buffa::Message for Cloud { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if self.flow_uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.flow_uid) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.compat.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compat.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.uid != 0i32 { + ::buffa::types::put_int32_field(1u32, self.uid, buf); + } + if self.flow_uid != 0i32 { + ::buffa::types::put_int32_field(2u32, self.flow_uid, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + if self.compat.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compat.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.flow_uid = ::buffa::types::decode_int32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compat.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.uid = 0i32; + self.flow_uid = 0i32; + self.x = 0f64; + self.y = 0f64; + self.compat = ::buffa::MessageField::none(); + } + } + /// Visual container for grouping related model elements. + /// x/y are center coordinates (matching the internal convention). + #[derive(Clone, PartialEq, Default)] + pub struct Group { + /// Field 1: `uid` + pub uid: i32, + /// Field 2: `name` + pub name: ::buffa::alloc::string::String, + /// Field 3: `x` pub x: f64, - #[prost(double, tag = "4")] + /// Field 4: `y` pub y: f64, - #[prost(message, optional, tag = "5")] - pub compat: ::core::option::Option, + /// Field 5: `width` + pub width: f64, + /// Field 6: `height` + pub height: f64, + /// Field 7: `is_mdl_view_marker` + pub is_mdl_view_marker: bool, + } + impl ::core::fmt::Debug for Group { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Group") + .field("uid", &self.uid) + .field("name", &self.name) + .field("x", &self.x) + .field("y", &self.y) + .field("width", &self.width) + .field("height", &self.height) + .field("is_mdl_view_marker", &self.is_mdl_view_marker) + .finish() + } + } + impl Group { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Group"; + } + ::buffa::impl_default_instance!(Group); + impl ::buffa::MessageName for Group { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ViewElement.Group"; + const FULL_NAME: &'static str = "project_io.ViewElement.Group"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ViewElement.Group"; + } + impl ::buffa::Message for Group { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.uid != 0i32 { + size += 1u64 + ::buffa::types::int32_encoded_len(self.uid) as u64; + } + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.width.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.height.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.is_mdl_view_marker { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.uid != 0i32 { + ::buffa::types::put_int32_field(1u32, self.uid, buf); + } + if !self.name.is_empty() { + ::buffa::types::put_string_field(2u32, &self.name, buf); + } + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.y, buf); + } + if self.width.to_bits() != 0u64 { + ::buffa::types::put_double_field(5u32, self.width, buf); + } + if self.height.to_bits() != 0u64 { + ::buffa::types::put_double_field(6u32, self.height, buf); + } + if self.is_mdl_view_marker { + ::buffa::types::put_bool_field(7u32, self.is_mdl_view_marker, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.uid = ::buffa::types::decode_int32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.width = ::buffa::types::decode_double(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.height = ::buffa::types::decode_double(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.is_mdl_view_marker = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.uid = 0i32; + self.name.clear(); + self.x = 0f64; + self.y = 0f64; + self.width = 0f64; + self.height = 0f64; + self.is_mdl_view_marker = false; + } + } + #[doc(inline)] + pub use super::__buffa::oneof::view_element::Element; +} +#[derive(Clone, PartialEq, Default)] +pub struct Rect { + /// Field 1: `x` + pub x: f64, + /// Field 2: `y` + pub y: f64, + /// Field 3: `width` + pub width: f64, + /// Field 4: `height` + pub height: f64, +} +impl ::core::fmt::Debug for Rect { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Rect") + .field("x", &self.x) + .field("y", &self.y) + .field("width", &self.width) + .field("height", &self.height) + .finish() + } +} +impl Rect { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Rect"; +} +::buffa::impl_default_instance!(Rect); +impl ::buffa::MessageName for Rect { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Rect"; + const FULL_NAME: &'static str = "project_io.Rect"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Rect"; +} +impl ::buffa::Message for Rect { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.x.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.y.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.width.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.height.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.x.to_bits() != 0u64 { + ::buffa::types::put_double_field(1u32, self.x, buf); + } + if self.y.to_bits() != 0u64 { + ::buffa::types::put_double_field(2u32, self.y, buf); + } + if self.width.to_bits() != 0u64 { + ::buffa::types::put_double_field(3u32, self.width, buf); + } + if self.height.to_bits() != 0u64 { + ::buffa::types::put_double_field(4u32, self.height, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.x = ::buffa::types::decode_double(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.y = ::buffa::types::decode_double(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.width = ::buffa::types::decode_double(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.height = ::buffa::types::decode_double(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.x = 0f64; + self.y = 0f64; + self.width = 0f64; + self.height = 0f64; + } +} +#[derive(Clone, PartialEq, Default)] +pub struct View { + /// Field 1: `kind` + pub kind: ::buffa::EnumValue, + /// background + /// + /// Field 3: `elements` + pub elements: ::buffa::alloc::vec::Vec, + /// Field 4: `viewBox` + pub view_box: ::buffa::MessageField>, + /// Field 5: `zoom` + pub zoom: f64, + /// Field 6: `use_lettered_polarity` + pub use_lettered_polarity: bool, + /// Field 7: `name` + pub name: ::buffa::alloc::string::String, + /// Field 8: `has_name` + pub has_name: bool, + /// Field 9: `font` + pub font: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for View { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("View") + .field("kind", &self.kind) + .field("elements", &self.elements) + .field("view_box", &self.view_box) + .field("zoom", &self.zoom) + .field("use_lettered_polarity", &self.use_lettered_polarity) + .field("name", &self.name) + .field("has_name", &self.has_name) + .field("font", &self.font) + .finish() + } +} +impl View { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.View"; +} +::buffa::impl_default_instance!(View); +impl ::buffa::MessageName for View { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "View"; + const FULL_NAME: &'static str = "project_io.View"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.View"; +} +impl ::buffa::Message for View { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + for v in &self.elements { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + if self.view_box.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.view_box.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + if self.zoom.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.use_lettered_polarity { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.has_name { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if let Some(ref v) = self.font { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.kind.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(1u32, val, buf); + } + } + for v in &self.elements { + ::buffa::types::put_len_delimited_header(3u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + if self.view_box.is_set() { + ::buffa::types::put_len_delimited_header(4u32, u64::from(__cache.consume_next()), buf); + self.view_box.write_to(__cache, buf); + } + if self.zoom.to_bits() != 0u64 { + ::buffa::types::put_double_field(5u32, self.zoom, buf); + } + if self.use_lettered_polarity { + ::buffa::types::put_bool_field(6u32, self.use_lettered_polarity, buf); + } + if !self.name.is_empty() { + ::buffa::types::put_string_field(7u32, &self.name, buf); + } + if self.has_name { + ::buffa::types::put_bool_field(8u32, self.has_name, buf); + } + if let Some(ref v) = self.font { + ::buffa::types::put_string_field(9u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.elements.push(elem); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.view_box.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.zoom = ::buffa::types::decode_double(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.use_lettered_polarity = ::buffa::types::decode_bool(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.has_name = ::buffa::types::decode_bool(buf)?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.font + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.kind = ::buffa::EnumValue::from(0); + self.elements.clear(); + self.view_box = ::buffa::MessageField::none(); + self.zoom = 0f64; + self.use_lettered_polarity = false; + self.name.clear(); + self.has_name = false; + self.font = ::core::option::Option::None; + } +} +pub mod view { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum ViewType { + /// INTERFACE = 1; + /// POPUP = 2; + /// VENDOR_SPECIFIC = 3; + STOCK_FLOW = 0i32, + } + impl ViewType { + ///Idiomatic alias for [`Self::STOCK_FLOW`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const StockFlow: Self = Self::STOCK_FLOW; + } + impl ::core::default::Default for ViewType { + fn default() -> Self { + Self::STOCK_FLOW + } + } + impl ::buffa::Enumeration for ViewType { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::STOCK_FLOW), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::STOCK_FLOW => "STOCK_FLOW", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "STOCK_FLOW" => ::core::option::Option::Some(Self::STOCK_FLOW), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[Self::STOCK_FLOW] + } + } +} +#[derive(Clone, PartialEq, Default)] +pub struct LoopMetadata { + /// Field 1: `uids` + pub uids: ::buffa::alloc::vec::Vec, + /// Field 2: `deleted` + pub deleted: bool, + /// Field 3: `name` + pub name: ::buffa::alloc::string::String, + /// Field 4: `description` + pub description: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for LoopMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("LoopMetadata") + .field("uids", &self.uids) + .field("deleted", &self.deleted) + .field("name", &self.name) + .field("description", &self.description) + .finish() + } +} +impl LoopMetadata { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.LoopMetadata"; +} +::buffa::impl_default_instance!(LoopMetadata); +impl ::buffa::MessageName for LoopMetadata { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "LoopMetadata"; + const FULL_NAME: &'static str = "project_io.LoopMetadata"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.LoopMetadata"; +} +impl ::buffa::Message for LoopMetadata { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.uids.is_empty() { + let payload: u64 = self + .uids + .iter() + .map(|&v| ::buffa::types::int32_encoded_len(v) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.deleted { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if !self.description.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.description) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.uids.is_empty() { + let payload: u64 = self + .uids + .iter() + .map(|&v| ::buffa::types::int32_encoded_len(v) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(1u32, payload, buf); + for &v in &self.uids { + ::buffa::types::encode_int32(v, buf); + } + } + if self.deleted { + ::buffa::types::put_bool_field(2u32, self.deleted, buf); + } + if !self.name.is_empty() { + ::buffa::types::put_string_field(3u32, &self.name, buf); + } + if !self.description.is_empty() { + ::buffa::types::put_string_field(4u32, &self.description, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = + usize::try_from(len).map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err(::buffa::DecodeError::UnexpectedEof); + } + if buf.chunk().len() >= len { + ::buffa::types::extend_packed_int32( + &buf.chunk()[..len], + &mut self.uids, + len, + )?; + buf.advance(len); + } else { + self.uids.reserve(len); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.uids + .push(::buffa::types::decode_int32_packed(&mut limited)?); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + self.uids.push(::buffa::types::decode_int32(buf)?); + } else { + return ::core::result::Result::Err(::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.deleted = ::buffa::types::decode_bool(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.description, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.uids.clear(); + self.deleted = false; + self.name.clear(); + self.description.clear(); + } +} +/// Marks a Model as a callable macro template and records its calling +/// convention. See datamodel::MacroSpec. +#[derive(Clone, PartialEq, Default)] +pub struct MacroSpec { + /// Field 1: `parameters` + pub parameters: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 2: `primary_output` + pub primary_output: ::buffa::alloc::string::String, + /// Field 3: `additional_outputs` + pub additional_outputs: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for MacroSpec { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MacroSpec") + .field("parameters", &self.parameters) + .field("primary_output", &self.primary_output) + .field("additional_outputs", &self.additional_outputs) + .finish() + } +} +impl MacroSpec { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.MacroSpec"; +} +::buffa::impl_default_instance!(MacroSpec); +impl ::buffa::MessageName for MacroSpec { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "MacroSpec"; + const FULL_NAME: &'static str = "project_io.MacroSpec"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.MacroSpec"; +} +impl ::buffa::Message for MacroSpec { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.parameters { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if !self.primary_output.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.primary_output) as u64; + } + for v in &self.additional_outputs { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.parameters { + ::buffa::types::put_string_field(1u32, v, buf); + } + if !self.primary_output.is_empty() { + ::buffa::types::put_string_field(2u32, &self.primary_output, buf); + } + for v in &self.additional_outputs { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.parameters.push(__elem); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.primary_output, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.additional_outputs.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.parameters.clear(); + self.primary_output.clear(); + self.additional_outputs.clear(); + } +} +/// Semantic/organizational group for categorizing model variables. +/// This is distinct from visual diagram groups (ViewElement.Group). +/// In Vensim, these are called "sectors". +#[derive(Clone, PartialEq, Default)] +pub struct ModelGroup { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `doc` + pub doc: ::buffa::alloc::string::String, + /// Field 3: `parent` + pub parent: ::buffa::alloc::string::String, + /// Field 4: `members` + pub members: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 5: `run_enabled` + pub run_enabled: bool, +} +impl ::core::fmt::Debug for ModelGroup { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ModelGroup") + .field("name", &self.name) + .field("doc", &self.doc) + .field("parent", &self.parent) + .field("members", &self.members) + .field("run_enabled", &self.run_enabled) + .finish() + } +} +impl ModelGroup { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ModelGroup"; +} +::buffa::impl_default_instance!(ModelGroup); +impl ::buffa::MessageName for ModelGroup { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ModelGroup"; + const FULL_NAME: &'static str = "project_io.ModelGroup"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ModelGroup"; +} +impl ::buffa::Message for ModelGroup { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if !self.doc.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.doc) as u64; + } + if !self.parent.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.parent) as u64; + } + for v in &self.members { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.run_enabled { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if !self.doc.is_empty() { + ::buffa::types::put_string_field(2u32, &self.doc, buf); + } + if !self.parent.is_empty() { + ::buffa::types::put_string_field(3u32, &self.parent, buf); + } + for v in &self.members { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.run_enabled { + ::buffa::types::put_bool_field(5u32, self.run_enabled, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.doc, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.members.push(__elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.run_enabled = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.doc.clear(); + self.parent.clear(); + self.members.clear(); + self.run_enabled = false; + } +} +#[derive(Clone, PartialEq, Default)] +pub struct Model { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// namespaces + /// no 'resource' or sim_specs in our normalized form + /// + /// Field 3: `variables` + pub variables: ::buffa::alloc::vec::Vec, + /// Field 4: `views` + pub views: ::buffa::alloc::vec::Vec, + /// Field 5: `loop_metadata` + pub loop_metadata: ::buffa::alloc::vec::Vec, + /// Field 6: `groups` + pub groups: ::buffa::alloc::vec::Vec, + /// Present only when this model is a callable macro template. A singular + /// proto3 message field is presence-tracked, so the generated Rust field is a + /// `buffa::MessageField` that distinguishes unset from empty. + /// + /// Field 7: `macro_spec` + pub macro_spec: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for Model { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Model") + .field("name", &self.name) + .field("variables", &self.variables) + .field("views", &self.views) + .field("loop_metadata", &self.loop_metadata) + .field("groups", &self.groups) + .field("macro_spec", &self.macro_spec) + .finish() + } +} +impl Model { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Model"; +} +::buffa::impl_default_instance!(Model); +impl ::buffa::MessageName for Model { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Model"; + const FULL_NAME: &'static str = "project_io.Model"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Model"; +} +impl ::buffa::Message for Model { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + for v in &self.variables { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + for v in &self.views { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + for v in &self.loop_metadata { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + for v in &self.groups { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + if self.macro_spec.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.macro_spec.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + for v in &self.variables { + ::buffa::types::put_len_delimited_header(3u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + for v in &self.views { + ::buffa::types::put_len_delimited_header(4u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + for v in &self.loop_metadata { + ::buffa::types::put_len_delimited_header(5u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + for v in &self.groups { + ::buffa::types::put_len_delimited_header(6u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + if self.macro_spec.is_set() { + ::buffa::types::put_len_delimited_header(7u32, u64::from(__cache.consume_next()), buf); + self.macro_spec.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.variables.push(elem); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.views.push(elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.loop_metadata.push(elem); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.groups.push(elem); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.macro_spec.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.variables.clear(); + self.views.clear(); + self.loop_metadata.clear(); + self.groups.clear(); + self.macro_spec = ::buffa::MessageField::none(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct Dt { + /// Field 1: `value` + pub value: f64, + /// Field 2: `is_reciprocal` + pub is_reciprocal: bool, +} +impl ::core::fmt::Debug for Dt { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Dt") + .field("value", &self.value) + .field("is_reciprocal", &self.is_reciprocal) + .finish() + } +} +impl Dt { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dt"; +} +::buffa::impl_default_instance!(Dt); +impl ::buffa::MessageName for Dt { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Dt"; + const FULL_NAME: &'static str = "project_io.Dt"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dt"; +} +impl ::buffa::Message for Dt { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.value.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.is_reciprocal { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.value.to_bits() != 0u64 { + ::buffa::types::put_double_field(1u32, self.value, buf); + } + if self.is_reciprocal { + ::buffa::types::put_bool_field(2u32, self.is_reciprocal, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.value = ::buffa::types::decode_double(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.is_reciprocal = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.value = 0f64; + self.is_reciprocal = false; + } +} +#[derive(Clone, PartialEq, Default)] +pub struct SimSpecs { + /// Field 1: `start` + pub start: f64, + /// Field 2: `stop` + pub stop: f64, + /// Field 3: `dt` + pub dt: ::buffa::MessageField>, + /// Field 4: `save_step` + pub save_step: ::buffa::MessageField>, + /// Field 5: `sim_method` + pub sim_method: ::buffa::EnumValue, + /// Field 6: `time_units` + pub time_units: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for SimSpecs { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SimSpecs") + .field("start", &self.start) + .field("stop", &self.stop) + .field("dt", &self.dt) + .field("save_step", &self.save_step) + .field("sim_method", &self.sim_method) + .field("time_units", &self.time_units) + .finish() + } +} +impl SimSpecs { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.SimSpecs"; +} +::buffa::impl_default_instance!(SimSpecs); +impl ::buffa::MessageName for SimSpecs { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "SimSpecs"; + const FULL_NAME: &'static str = "project_io.SimSpecs"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.SimSpecs"; +} +impl ::buffa::Message for SimSpecs { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.start.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.stop.to_bits() != 0u64 { + size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64; + } + if self.dt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.dt.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + if self.save_step.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.save_step.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + { + let val = self.sim_method.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if let Some(ref v) = self.time_units { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.start.to_bits() != 0u64 { + ::buffa::types::put_double_field(1u32, self.start, buf); + } + if self.stop.to_bits() != 0u64 { + ::buffa::types::put_double_field(2u32, self.stop, buf); + } + if self.dt.is_set() { + ::buffa::types::put_len_delimited_header(3u32, u64::from(__cache.consume_next()), buf); + self.dt.write_to(__cache, buf); + } + if self.save_step.is_set() { + ::buffa::types::put_len_delimited_header(4u32, u64::from(__cache.consume_next()), buf); + self.save_step.write_to(__cache, buf); + } + { + let val = self.sim_method.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(5u32, val, buf); + } + } + if let Some(ref v) = self.time_units { + ::buffa::types::put_string_field(6u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.start = ::buffa::types::decode_double(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Fixed64)?; + self.stop = ::buffa::types::decode_double(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.dt.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.save_step.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.sim_method = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.time_units + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.start = 0f64; + self.stop = 0f64; + self.dt = ::buffa::MessageField::none(); + self.save_step = ::buffa::MessageField::none(); + self.sim_method = ::buffa::EnumValue::from(0); + self.time_units = ::core::option::Option::None; + } +} +#[derive(Clone, PartialEq, Default)] +pub struct Dimension { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `obsolete_elements` + pub obsolete_elements: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Vensim dimension mapping: when this dimension "maps to" another, + /// elements of this dimension correspond positionally to elements of + /// the target dimension. e.g., "DimA: A1, A2, A3 -\> DimB" means + /// A1\<-\>B1, A2\<-\>B2, A3\<-\>B3. This is used when a variable indexed + /// by DimB references variables indexed by DimA. + /// + /// Field 5: `maps_to` + pub maps_to: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 6: `mappings` + pub mappings: ::buffa::alloc::vec::Vec, + /// For indexed subdimensions, the name of the parent dimension. + /// e.g., SubIndex(3) with parent="FullIndex" means SubIndex is a + /// subdimension of FullIndex(5). + /// + /// Field 7: `parent` + pub parent: ::core::option::Option<::buffa::alloc::string::String>, + pub dimension: ::core::option::Option<__buffa::oneof::dimension::Dimension>, +} +impl ::core::fmt::Debug for Dimension { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Dimension") + .field("name", &self.name) + .field("obsolete_elements", &self.obsolete_elements) + .field("maps_to", &self.maps_to) + .field("mappings", &self.mappings) + .field("parent", &self.parent) + .field("dimension", &self.dimension) + .finish() + } +} +impl Dimension { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dimension"; +} +::buffa::impl_default_instance!(Dimension); +impl ::buffa::MessageName for Dimension { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Dimension"; + const FULL_NAME: &'static str = "project_io.Dimension"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dimension"; +} +impl ::buffa::Message for Dimension { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + for v in &self.obsolete_elements { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let ::core::option::Option::Some(ref v) = self.dimension { + match v { + __buffa::oneof::dimension::Dimension::Elements(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::dimension::Dimension::Size(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + } + } + if let Some(ref v) = self.maps_to { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.mappings { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + if let Some(ref v) = self.parent { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + for v in &self.obsolete_elements { + ::buffa::types::put_string_field(2u32, v, buf); + } + if let ::core::option::Option::Some(ref v) = self.dimension { + match v { + __buffa::oneof::dimension::Dimension::Elements(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::dimension::Dimension::Size(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + if let Some(ref v) = self.maps_to { + ::buffa::types::put_string_field(5u32, v, buf); + } + for v in &self.mappings { + ::buffa::types::put_len_delimited_header(6u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.parent { + ::buffa::types::put_string_field(7u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.obsolete_elements.push(__elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::dimension::Dimension::Elements(ref mut existing), + ) = self.dimension + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.dimension = ::core::option::Option::Some( + __buffa::oneof::dimension::Dimension::Elements(val), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some(__buffa::oneof::dimension::Dimension::Size( + ref mut existing, + )) = self.dimension + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.dimension = ::core::option::Option::Some( + __buffa::oneof::dimension::Dimension::Size(val), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.maps_to + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.mappings.push(elem); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.parent + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.obsolete_elements.clear(); + self.dimension = ::core::option::Option::None; + self.maps_to = ::core::option::Option::None; + self.mappings.clear(); + self.parent = ::core::option::Option::None; + } +} +pub mod dimension { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + pub struct DimensionElements { + /// Field 1: `elements` + pub elements: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + } + impl ::core::fmt::Debug for DimensionElements { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DimensionElements") + .field("elements", &self.elements) + .finish() + } + } + impl DimensionElements { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Dimension.DimensionElements"; + } + ::buffa::impl_default_instance!(DimensionElements); + impl ::buffa::MessageName for DimensionElements { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Dimension.DimensionElements"; + const FULL_NAME: &'static str = "project_io.Dimension.DimensionElements"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dimension.DimensionElements"; + } + impl ::buffa::Message for DimensionElements { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.elements { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.elements { + ::buffa::types::put_string_field(1u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.elements.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.elements.clear(); + } + } + #[derive(Clone, PartialEq, Default)] + pub struct DimensionSize { + /// Field 1: `size` + pub size: u32, + } + impl ::core::fmt::Debug for DimensionSize { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DimensionSize") + .field("size", &self.size) + .finish() + } + } + impl DimensionSize { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dimension.DimensionSize"; + } + ::buffa::impl_default_instance!(DimensionSize); + impl ::buffa::MessageName for DimensionSize { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Dimension.DimensionSize"; + const FULL_NAME: &'static str = "project_io.Dimension.DimensionSize"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dimension.DimensionSize"; + } + impl ::buffa::Message for DimensionSize { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.size != 0u32 { + size += 1u64 + ::buffa::types::uint32_encoded_len(self.size) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.size != 0u32 { + ::buffa::types::put_uint32_field(1u32, self.size, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.size = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.size = 0u32; + } + } + #[derive(Clone, PartialEq, Default)] + pub struct DimensionMapping { + /// Field 1: `target` + pub target: ::buffa::alloc::string::String, + /// Field 2: `entries` + pub entries: ::buffa::alloc::vec::Vec, + } + impl ::core::fmt::Debug for DimensionMapping { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DimensionMapping") + .field("target", &self.target) + .field("entries", &self.entries) + .finish() + } + } + impl DimensionMapping { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Dimension.DimensionMapping"; + } + ::buffa::impl_default_instance!(DimensionMapping); + impl ::buffa::MessageName for DimensionMapping { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Dimension.DimensionMapping"; + const FULL_NAME: &'static str = "project_io.Dimension.DimensionMapping"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Dimension.DimensionMapping"; + } + impl ::buffa::Message for DimensionMapping { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.target.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.target) as u64; + } + for v in &self.entries { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += 1u64 + + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.target.is_empty() { + ::buffa::types::put_string_field(1u32, &self.target, buf); + } + for v in &self.entries { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.target, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.entries.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.target.clear(); + self.entries.clear(); + } + } + pub mod dimension_mapping { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + pub struct ElementMapEntry { + /// Field 1: `from_element` + pub from_element: ::buffa::alloc::string::String, + /// Field 2: `to_element` + pub to_element: ::buffa::alloc::string::String, + } + impl ::core::fmt::Debug for ElementMapEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ElementMapEntry") + .field("from_element", &self.from_element) + .field("to_element", &self.to_element) + .finish() + } + } + impl ElementMapEntry { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Dimension.DimensionMapping.ElementMapEntry"; + } + ::buffa::impl_default_instance!(ElementMapEntry); + impl ::buffa::MessageName for ElementMapEntry { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Dimension.DimensionMapping.ElementMapEntry"; + const FULL_NAME: &'static str = "project_io.Dimension.DimensionMapping.ElementMapEntry"; + const TYPE_URL: &'static str = + "type.googleapis.com/project_io.Dimension.DimensionMapping.ElementMapEntry"; + } + impl ::buffa::Message for ElementMapEntry { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.from_element.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.from_element) as u64; + } + if !self.to_element.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.to_element) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.from_element.is_empty() { + ::buffa::types::put_string_field(1u32, &self.from_element, buf); + } + if !self.to_element.is_empty() { + ::buffa::types::put_string_field(2u32, &self.to_element, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.from_element, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.to_element, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.from_element.clear(); + self.to_element.clear(); + } + } + } + #[doc(inline)] + pub use super::__buffa::oneof::dimension::Dimension; +} +#[derive(Clone, PartialEq, Default)] +pub struct Unit { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `equation` + pub equation: ::buffa::alloc::string::String, + /// Field 3: `disabled` + pub disabled: bool, + /// Field 4: `alias` + pub alias: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for Unit { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Unit") + .field("name", &self.name) + .field("equation", &self.equation) + .field("disabled", &self.disabled) + .field("alias", &self.alias) + .finish() + } +} +impl Unit { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Unit"; +} +::buffa::impl_default_instance!(Unit); +impl ::buffa::MessageName for Unit { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Unit"; + const FULL_NAME: &'static str = "project_io.Unit"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Unit"; +} +impl ::buffa::Message for Unit { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if !self.equation.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.equation) as u64; + } + if self.disabled { + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + } + for v in &self.alias { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if !self.equation.is_empty() { + ::buffa::types::put_string_field(2u32, &self.equation, buf); + } + if self.disabled { + ::buffa::types::put_bool_field(3u32, self.disabled, buf); + } + for v in &self.alias { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.equation, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.disabled = ::buffa::types::decode_bool(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.alias.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.equation.clear(); + self.disabled = false; + self.alias.clear(); + } +} +/// often we want to import or export a project to a string; whether it is +/// an XMILE model, Vensim, or something else. This is very useful for +/// debugging import problems, and can be used to send both the protobuf and +/// XMILE output from the frontend to the filesystem +#[derive(Clone, PartialEq, Default)] +pub struct Source { + /// Field 1: `extension` + pub extension: ::buffa::EnumValue, + /// Field 2: `content` + pub content: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for Source { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Source") + .field("extension", &self.extension) + .field("content", &self.content) + .finish() + } +} +impl Source { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Source"; +} +::buffa::impl_default_instance!(Source); +impl ::buffa::MessageName for Source { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Source"; + const FULL_NAME: &'static str = "project_io.Source"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Source"; +} +impl ::buffa::Message for Source { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.extension.to_i32(); + if val != 0 { + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + } + if !self.content.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.content) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.extension.to_i32(); + if val != 0 { + ::buffa::types::put_int32_field(1u32, val, buf); + } + } + if !self.content.is_empty() { + ::buffa::types::put_string_field(2u32, &self.content, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.extension = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.content, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.extension = ::buffa::EnumValue::from(0); + self.content.clear(); + } +} +pub mod source { + #[allow(unused_imports)] + use super::*; + #[allow(non_camel_case_types)] + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] + #[repr(i32)] + pub enum Extension { + UNSPECIFIED = 0i32, + XMILE = 1i32, + VENSIM = 2i32, + } + impl Extension { + ///Idiomatic alias for [`Self::UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::UNSPECIFIED; + ///Idiomatic alias for [`Self::XMILE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Xmile: Self = Self::XMILE; + ///Idiomatic alias for [`Self::VENSIM`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Vensim: Self = Self::VENSIM; + } + impl ::core::default::Default for Extension { + fn default() -> Self { + Self::UNSPECIFIED + } + } + impl ::buffa::Enumeration for Extension { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::XMILE), + 2i32 => ::core::option::Option::Some(Self::VENSIM), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::UNSPECIFIED => "UNSPECIFIED", + Self::XMILE => "XMILE", + Self::VENSIM => "VENSIM", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "UNSPECIFIED" => ::core::option::Option::Some(Self::UNSPECIFIED), + "XMILE" => ::core::option::Option::Some(Self::XMILE), + "VENSIM" => ::core::option::Option::Some(Self::VENSIM), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[Self::UNSPECIFIED, Self::XMILE, Self::VENSIM] + } + } +} +#[derive(Clone, PartialEq, Default)] +pub struct ProjectPatch { + /// Field 1: `project_ops` + pub project_ops: ::buffa::alloc::vec::Vec, + /// Field 2: `models` + pub models: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for ProjectPatch { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProjectPatch") + .field("project_ops", &self.project_ops) + .field("models", &self.models) + .finish() + } +} +impl ProjectPatch { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ProjectPatch"; +} +::buffa::impl_default_instance!(ProjectPatch); +impl ::buffa::MessageName for ProjectPatch { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ProjectPatch"; + const FULL_NAME: &'static str = "project_io.ProjectPatch"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ProjectPatch"; +} +impl ::buffa::Message for ProjectPatch { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.project_ops { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + for v in &self.models { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.project_ops { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + for v in &self.models { + ::buffa::types::put_len_delimited_header(2u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.project_ops.push(elem); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.models.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.project_ops.clear(); + self.models.clear(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct ModelPatch { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `ops` + pub ops: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for ModelPatch { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ModelPatch") + .field("name", &self.name) + .field("ops", &self.ops) + .finish() + } +} +impl ModelPatch { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ModelPatch"; +} +::buffa::impl_default_instance!(ModelPatch); +impl ::buffa::MessageName for ModelPatch { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ModelPatch"; + const FULL_NAME: &'static str = "project_io.ModelPatch"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ModelPatch"; +} +impl ::buffa::Message for ModelPatch { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + for v in &self.ops { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + for v in &self.ops { + ::buffa::types::put_len_delimited_header(2u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.ops.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) } - /// Visual container for grouping related model elements. - /// x/y are center coordinates (matching the internal convention). - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Group { - #[prost(int32, tag = "1")] - pub uid: i32, - #[prost(string, tag = "2")] - pub name: ::prost::alloc::string::String, - #[prost(double, tag = "3")] - pub x: f64, - #[prost(double, tag = "4")] - pub y: f64, - #[prost(double, tag = "5")] - pub width: f64, - #[prost(double, tag = "6")] - pub height: f64, - #[prost(bool, tag = "7")] - pub is_mdl_view_marker: bool, + fn clear(&mut self) { + self.name.clear(); + self.ops.clear(); } - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum LabelSide { - Top = 0, - Left = 1, - Center = 2, - Bottom = 3, - Right = 4, +} +#[derive(Clone, PartialEq, Default)] +pub struct ProjectOperation { + pub op: ::core::option::Option<__buffa::oneof::project_operation::Op>, +} +impl ::core::fmt::Debug for ProjectOperation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProjectOperation") + .field("op", &self.op) + .finish() } - impl LabelSide { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Top => "TOP", - Self::Left => "LEFT", - Self::Center => "CENTER", - Self::Bottom => "BOTTOM", - Self::Right => "RIGHT", +} +impl ProjectOperation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ProjectOperation"; +} +::buffa::impl_default_instance!(ProjectOperation); +impl ::buffa::MessageName for ProjectOperation { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ProjectOperation"; + const FULL_NAME: &'static str = "project_io.ProjectOperation"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ProjectOperation"; +} +impl ::buffa::Message for ProjectOperation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.op { + match v { + __buffa::oneof::project_operation::Op::SetSimSpecs(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::project_operation::Op::SetSource(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "TOP" => Some(Self::Top), - "LEFT" => Some(Self::Left), - "CENTER" => Some(Self::Center), - "BOTTOM" => Some(Self::Bottom), - "RIGHT" => Some(Self::Right), - _ => None, - } - } - } - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Element { - #[prost(message, tag = "1")] - Aux(Aux), - #[prost(message, tag = "2")] - Stock(Stock), - #[prost(message, tag = "3")] - Flow(Flow), - #[prost(message, tag = "4")] - Link(Link), - #[prost(message, tag = "5")] - Module(Module), - #[prost(message, tag = "6")] - Alias(Alias), - #[prost(message, tag = "7")] - Cloud(Cloud), - #[prost(message, tag = "8")] - Group(Group), - } -} -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct Rect { - #[prost(double, tag = "1")] - pub x: f64, - #[prost(double, tag = "2")] - pub y: f64, - #[prost(double, tag = "3")] - pub width: f64, - #[prost(double, tag = "4")] - pub height: f64, + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.op { + match v { + __buffa::oneof::project_operation::Op::SetSimSpecs(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::project_operation::Op::SetSource(x) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::project_operation::Op::SetSimSpecs(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::project_operation::Op::SetSimSpecs(val), + ); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::project_operation::Op::SetSource(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::project_operation::Op::SetSource(val), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.op = ::core::option::Option::None; + } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct View { - #[prost(enumeration = "view::ViewType", tag = "1")] - pub kind: i32, - /// background - #[prost(message, repeated, tag = "3")] - pub elements: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "4")] - pub view_box: ::core::option::Option, - #[prost(double, tag = "5")] - pub zoom: f64, - #[prost(bool, tag = "6")] - pub use_lettered_polarity: bool, - #[prost(string, tag = "7")] - pub name: ::prost::alloc::string::String, - #[prost(bool, tag = "8")] - pub has_name: bool, - #[prost(string, optional, tag = "9")] - pub font: ::core::option::Option<::prost::alloc::string::String>, +pub mod project_operation { + #[doc(inline)] + pub use super::__buffa::oneof::project_operation::Op; + #[allow(unused_imports)] + use super::*; } -/// Nested message and enum types in `View`. -pub mod view { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum ViewType { - /// INTERFACE = 1; - /// POPUP = 2; - /// VENDOR_SPECIFIC = 3; - StockFlow = 0, +#[derive(Clone, PartialEq, Default)] +pub struct ModelOperation { + pub op: ::core::option::Option<__buffa::oneof::model_operation::Op>, +} +impl ::core::fmt::Debug for ModelOperation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ModelOperation") + .field("op", &self.op) + .finish() } - impl ViewType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::StockFlow => "STOCK_FLOW", +} +impl ModelOperation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.ModelOperation"; +} +::buffa::impl_default_instance!(ModelOperation); +impl ::buffa::MessageName for ModelOperation { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "ModelOperation"; + const FULL_NAME: &'static str = "project_io.ModelOperation"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.ModelOperation"; +} +impl ::buffa::Message for ModelOperation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.op { + match v { + __buffa::oneof::model_operation::Op::UpsertStock(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::UpsertFlow(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::UpsertAux(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::UpsertModule(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::DeleteVariable(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::RenameVariable(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::UpsertView(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::DeleteView(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } + __buffa::oneof::model_operation::Op::UpdateStockFlows(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size += + 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; + } } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "STOCK_FLOW" => Some(Self::StockFlow), - _ => None, + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.op { + match v { + __buffa::oneof::model_operation::Op::UpsertStock(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::UpsertFlow(x) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::UpsertAux(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::UpsertModule(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::DeleteVariable(x) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::RenameVariable(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::UpsertView(x) => { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::DeleteView(x) => { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::model_operation::Op::UpdateStockFlows(x) => { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertStock(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertStock(val), + ); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertFlow(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertFlow(val), + ); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertAux(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertAux(val), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertModule(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertModule(val), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::DeleteVariable(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::DeleteVariable(val), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::RenameVariable(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::RenameVariable(val), + ); + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertView(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpsertView(val), + ); + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::DeleteView(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::DeleteView(val), + ); + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpdateStockFlows(ref mut existing), + ) = self.op + { + ::buffa::Message::merge_length_delimited(existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.op = ::core::option::Option::Some( + __buffa::oneof::model_operation::Op::UpdateStockFlows(val), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; } } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.op = ::core::option::Option::None; } } -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct LoopMetadata { - #[prost(int32, repeated, tag = "1")] - pub uids: ::prost::alloc::vec::Vec, - #[prost(bool, tag = "2")] - pub deleted: bool, - #[prost(string, tag = "3")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub description: ::prost::alloc::string::String, +pub mod model_operation { + #[doc(inline)] + pub use super::__buffa::oneof::model_operation::Op; + #[allow(unused_imports)] + use super::*; } -/// Marks a Model as a callable macro template and records its calling -/// convention. See datamodel::MacroSpec. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct MacroSpec { - #[prost(string, repeated, tag = "1")] - pub parameters: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, tag = "2")] - pub primary_output: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "3")] - pub additional_outputs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +/// Updates only the inflows/outflows of an existing stock, preserving all other fields. +/// Use this when connecting/disconnecting flows from stocks in the UI. +#[derive(Clone, PartialEq, Default)] +pub struct UpdateStockFlowsOp { + /// Field 1: `ident` + pub ident: ::buffa::alloc::string::String, + /// Field 2: `inflows` + pub inflows: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 3: `outflows` + pub outflows: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, } -/// Semantic/organizational group for categorizing model variables. -/// This is distinct from visual diagram groups (ViewElement.Group). -/// In Vensim, these are called "sectors". -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ModelGroup { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub doc: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub parent: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "4")] - pub members: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(bool, tag = "5")] - pub run_enabled: bool, +impl ::core::fmt::Debug for UpdateStockFlowsOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpdateStockFlowsOp") + .field("ident", &self.ident) + .field("inflows", &self.inflows) + .field("outflows", &self.outflows) + .finish() + } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Model { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - /// namespaces - /// no 'resource' or sim_specs in our normalized form - #[prost(message, repeated, tag = "3")] - pub variables: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "4")] - pub views: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "5")] - pub loop_metadata: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "6")] - pub groups: ::prost::alloc::vec::Vec, - /// Present only when this model is a callable macro template. A singular - /// proto3 message field is presence-tracked, so prost generates it as - /// Option. - #[prost(message, optional, tag = "7")] - pub macro_spec: ::core::option::Option, +impl UpdateStockFlowsOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpdateStockFlowsOp"; } -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct Dt { - #[prost(double, tag = "1")] - pub value: f64, - #[prost(bool, tag = "2")] - pub is_reciprocal: bool, +::buffa::impl_default_instance!(UpdateStockFlowsOp); +impl ::buffa::MessageName for UpdateStockFlowsOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "UpdateStockFlowsOp"; + const FULL_NAME: &'static str = "project_io.UpdateStockFlowsOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpdateStockFlowsOp"; } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SimSpecs { - #[prost(double, tag = "1")] - pub start: f64, - #[prost(double, tag = "2")] - pub stop: f64, - #[prost(message, optional, tag = "3")] - pub dt: ::core::option::Option
, - #[prost(message, optional, tag = "4")] - pub save_step: ::core::option::Option
, - #[prost(enumeration = "SimMethod", tag = "5")] - pub sim_method: i32, - #[prost(string, optional, tag = "6")] - pub time_units: ::core::option::Option<::prost::alloc::string::String>, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Dimension { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "2")] - pub obsolete_elements: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - /// Vensim dimension mapping: when this dimension "maps to" another, - /// elements of this dimension correspond positionally to elements of - /// the target dimension. e.g., "DimA: A1, A2, A3 -> DimB" means - /// A1<->B1, A2<->B2, A3<->B3. This is used when a variable indexed - /// by DimB references variables indexed by DimA. - #[prost(string, optional, tag = "5")] - pub maps_to: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "6")] - pub mappings: ::prost::alloc::vec::Vec, - /// For indexed subdimensions, the name of the parent dimension. - /// e.g., SubIndex(3) with parent="FullIndex" means SubIndex is a - /// subdimension of FullIndex(5). - #[prost(string, optional, tag = "7")] - pub parent: ::core::option::Option<::prost::alloc::string::String>, - #[prost(oneof = "dimension::Dimension", tags = "3, 4")] - pub dimension: ::core::option::Option, +impl ::buffa::Message for UpdateStockFlowsOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.ident.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.ident) as u64; + } + for v in &self.inflows { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.outflows { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.ident.is_empty() { + ::buffa::types::put_string_field(1u32, &self.ident, buf); + } + for v in &self.inflows { + ::buffa::types::put_string_field(2u32, v, buf); + } + for v in &self.outflows { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ident, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.inflows.push(__elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory(::buffa::__private::element_footprint(&__elem))?; + self.outflows.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ident.clear(); + self.inflows.clear(); + self.outflows.clear(); + } } -/// Nested message and enum types in `Dimension`. -pub mod dimension { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct DimensionElements { - #[prost(string, repeated, tag = "1")] - pub elements: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +#[derive(Clone, PartialEq, Default)] +pub struct SetSimSpecsOp { + /// Field 1: `sim_specs` + pub sim_specs: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for SetSimSpecsOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SetSimSpecsOp") + .field("sim_specs", &self.sim_specs) + .finish() } - #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] - pub struct DimensionSize { - #[prost(uint32, tag = "1")] - pub size: u32, +} +impl SetSimSpecsOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.SetSimSpecsOp"; +} +::buffa::impl_default_instance!(SetSimSpecsOp); +impl ::buffa::MessageName for SetSimSpecsOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "SetSimSpecsOp"; + const FULL_NAME: &'static str = "project_io.SetSimSpecsOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.SetSimSpecsOp"; +} +impl ::buffa::Message for SetSimSpecsOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.sim_specs.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sim_specs.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sim_specs.is_set() { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + self.sim_specs.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.sim_specs.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sim_specs = ::buffa::MessageField::none(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct UpsertStockOp { + /// Field 1: `stock` + pub stock: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for UpsertStockOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpsertStockOp") + .field("stock", &self.stock) + .finish() + } +} +impl UpsertStockOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertStockOp"; +} +::buffa::impl_default_instance!(UpsertStockOp); +impl ::buffa::MessageName for UpsertStockOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "UpsertStockOp"; + const FULL_NAME: &'static str = "project_io.UpsertStockOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertStockOp"; +} +impl ::buffa::Message for UpsertStockOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.stock.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.stock.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.stock.is_set() { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + self.stock.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.stock.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.stock = ::buffa::MessageField::none(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct UpsertFlowOp { + /// Field 1: `flow` + pub flow: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for UpsertFlowOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpsertFlowOp") + .field("flow", &self.flow) + .finish() + } +} +impl UpsertFlowOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertFlowOp"; +} +::buffa::impl_default_instance!(UpsertFlowOp); +impl ::buffa::MessageName for UpsertFlowOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "UpsertFlowOp"; + const FULL_NAME: &'static str = "project_io.UpsertFlowOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertFlowOp"; +} +impl ::buffa::Message for UpsertFlowOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.flow.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.flow.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.flow.is_set() { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + self.flow.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.flow.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.flow = ::buffa::MessageField::none(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct UpsertAuxOp { + /// Field 1: `aux` + pub aux: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for UpsertAuxOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpsertAuxOp") + .field("aux", &self.aux) + .finish() + } +} +impl UpsertAuxOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertAuxOp"; +} +::buffa::impl_default_instance!(UpsertAuxOp); +impl ::buffa::MessageName for UpsertAuxOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "UpsertAuxOp"; + const FULL_NAME: &'static str = "project_io.UpsertAuxOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertAuxOp"; +} +impl ::buffa::Message for UpsertAuxOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.aux.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.aux.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.aux.is_set() { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + self.aux.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.aux.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.aux = ::buffa::MessageField::none(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct UpsertModuleOp { + /// Field 1: `module` + pub module: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for UpsertModuleOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpsertModuleOp") + .field("module", &self.module) + .finish() + } +} +impl UpsertModuleOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertModuleOp"; +} +::buffa::impl_default_instance!(UpsertModuleOp); +impl ::buffa::MessageName for UpsertModuleOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "UpsertModuleOp"; + const FULL_NAME: &'static str = "project_io.UpsertModuleOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertModuleOp"; +} +impl ::buffa::Message for UpsertModuleOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.module.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.module.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.module.is_set() { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + self.module.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.module.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.module = ::buffa::MessageField::none(); + } +} +#[derive(Clone, PartialEq, Default)] +pub struct DeleteVariableOp { + /// Field 1: `ident` + pub ident: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for DeleteVariableOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DeleteVariableOp") + .field("ident", &self.ident) + .finish() + } +} +impl DeleteVariableOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.DeleteVariableOp"; +} +::buffa::impl_default_instance!(DeleteVariableOp); +impl ::buffa::MessageName for DeleteVariableOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "DeleteVariableOp"; + const FULL_NAME: &'static str = "project_io.DeleteVariableOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.DeleteVariableOp"; +} +impl ::buffa::Message for DeleteVariableOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.ident.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.ident) as u64; + } + ::buffa::saturate_size(size) } - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct DimensionMapping { - #[prost(string, tag = "1")] - pub target: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub entries: ::prost::alloc::vec::Vec, + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.ident.is_empty() { + ::buffa::types::put_string_field(1u32, &self.ident, buf); + } } - /// Nested message and enum types in `DimensionMapping`. - pub mod dimension_mapping { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] - pub struct ElementMapEntry { - #[prost(string, tag = "1")] - pub from_element: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub to_element: ::prost::alloc::string::String, + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ident, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } } + ::core::result::Result::Ok(()) } - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Dimension { - #[prost(message, tag = "3")] - Elements(DimensionElements), - #[prost(message, tag = "4")] - Size(DimensionSize), + fn clear(&mut self) { + self.ident.clear(); } } -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Unit { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub equation: ::prost::alloc::string::String, - #[prost(bool, tag = "3")] - pub disabled: bool, - #[prost(string, repeated, tag = "4")] - pub alias: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +#[derive(Clone, PartialEq, Default)] +pub struct RenameVariableOp { + /// Field 1: `from` + pub from: ::buffa::alloc::string::String, + /// Field 2: `to` + pub to: ::buffa::alloc::string::String, } -/// often we want to import or export a project to a string; whether it is -/// an XMILE model, Vensim, or something else. This is very useful for -/// debugging import problems, and can be used to send both the protobuf and -/// XMILE output from the frontend to the filesystem -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Source { - #[prost(enumeration = "source::Extension", tag = "1")] - pub extension: i32, - #[prost(string, tag = "2")] - pub content: ::prost::alloc::string::String, +impl ::core::fmt::Debug for RenameVariableOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RenameVariableOp") + .field("from", &self.from) + .field("to", &self.to) + .finish() + } } -/// Nested message and enum types in `Source`. -pub mod source { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum Extension { - Unspecified = 0, - Xmile = 1, - Vensim = 2, +impl RenameVariableOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.RenameVariableOp"; +} +::buffa::impl_default_instance!(RenameVariableOp); +impl ::buffa::MessageName for RenameVariableOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "RenameVariableOp"; + const FULL_NAME: &'static str = "project_io.RenameVariableOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.RenameVariableOp"; +} +impl ::buffa::Message for RenameVariableOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.from.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.from) as u64; + } + if !self.to.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.to) as u64; + } + ::buffa::saturate_size(size) } - impl Extension { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "UNSPECIFIED", - Self::Xmile => "XMILE", - Self::Vensim => "VENSIM", - } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.from.is_empty() { + ::buffa::types::put_string_field(1u32, &self.from, buf); } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED" => Some(Self::Unspecified), - "XMILE" => Some(Self::Xmile), - "VENSIM" => Some(Self::Vensim), - _ => None, + if !self.to.is_empty() { + ::buffa::types::put_string_field(2u32, &self.to, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.from, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.to, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; } } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.from.clear(); + self.to.clear(); } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ProjectPatch { - #[prost(message, repeated, tag = "1")] - pub project_ops: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "2")] - pub models: ::prost::alloc::vec::Vec, +#[derive(Clone, PartialEq, Default)] +pub struct UpsertViewOp { + /// Field 1: `index` + pub index: u32, + /// Field 2: `view` + pub view: ::buffa::MessageField>, } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ModelPatch { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub ops: ::prost::alloc::vec::Vec, +impl ::core::fmt::Debug for UpsertViewOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpsertViewOp") + .field("index", &self.index) + .field("view", &self.view) + .finish() + } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ProjectOperation { - #[prost(oneof = "project_operation::Op", tags = "1, 2")] - pub op: ::core::option::Option, +impl UpsertViewOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertViewOp"; } -/// Nested message and enum types in `ProjectOperation`. -pub mod project_operation { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Op { - #[prost(message, tag = "1")] - SetSimSpecs(super::SetSimSpecsOp), - #[prost(message, tag = "2")] - SetSource(super::SetSourceOp), +::buffa::impl_default_instance!(UpsertViewOp); +impl ::buffa::MessageName for UpsertViewOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "UpsertViewOp"; + const FULL_NAME: &'static str = "project_io.UpsertViewOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.UpsertViewOp"; +} +impl ::buffa::Message for UpsertViewOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.index != 0u32 { + size += 1u64 + ::buffa::types::uint32_encoded_len(self.index) as u64; + } + if self.view.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.view.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.index != 0u32 { + ::buffa::types::put_uint32_field(1u32, self.index, buf); + } + if self.view.is_set() { + ::buffa::types::put_len_delimited_header(2u32, u64::from(__cache.consume_next()), buf); + self.view.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.index = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.view.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.index = 0u32; + self.view = ::buffa::MessageField::none(); } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ModelOperation { - #[prost(oneof = "model_operation::Op", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9")] - pub op: ::core::option::Option, +#[derive(Clone, PartialEq, Default)] +pub struct DeleteViewOp { + /// Field 1: `index` + pub index: u32, } -/// Nested message and enum types in `ModelOperation`. -pub mod model_operation { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Op { - #[prost(message, tag = "1")] - UpsertStock(super::UpsertStockOp), - #[prost(message, tag = "2")] - UpsertFlow(super::UpsertFlowOp), - #[prost(message, tag = "3")] - UpsertAux(super::UpsertAuxOp), - #[prost(message, tag = "4")] - UpsertModule(super::UpsertModuleOp), - #[prost(message, tag = "5")] - DeleteVariable(super::DeleteVariableOp), - #[prost(message, tag = "6")] - RenameVariable(super::RenameVariableOp), - #[prost(message, tag = "7")] - UpsertView(super::UpsertViewOp), - #[prost(message, tag = "8")] - DeleteView(super::DeleteViewOp), - #[prost(message, tag = "9")] - UpdateStockFlows(super::UpdateStockFlowsOp), +impl ::core::fmt::Debug for DeleteViewOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DeleteViewOp") + .field("index", &self.index) + .finish() } } -/// Updates only the inflows/outflows of an existing stock, preserving all other fields. -/// Use this when connecting/disconnecting flows from stocks in the UI. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct UpdateStockFlowsOp { - #[prost(string, tag = "1")] - pub ident: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "2")] - pub inflows: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "3")] - pub outflows: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SetSimSpecsOp { - #[prost(message, optional, tag = "1")] - pub sim_specs: ::core::option::Option, +impl DeleteViewOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.DeleteViewOp"; } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpsertStockOp { - #[prost(message, optional, tag = "1")] - pub stock: ::core::option::Option, +::buffa::impl_default_instance!(DeleteViewOp); +impl ::buffa::MessageName for DeleteViewOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "DeleteViewOp"; + const FULL_NAME: &'static str = "project_io.DeleteViewOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.DeleteViewOp"; } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpsertFlowOp { - #[prost(message, optional, tag = "1")] - pub flow: ::core::option::Option, +impl ::buffa::Message for DeleteViewOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.index != 0u32 { + size += 1u64 + ::buffa::types::uint32_encoded_len(self.index) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, _cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.index != 0u32 { + ::buffa::types::put_uint32_field(1u32, self.index, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type(tag, ::buffa::encoding::WireType::Varint)?; + self.index = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.index = 0u32; + } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpsertAuxOp { - #[prost(message, optional, tag = "1")] - pub aux: ::core::option::Option, +#[derive(Clone, PartialEq, Default)] +pub struct SetSourceOp { + /// Field 1: `source` + pub source: ::buffa::MessageField>, } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpsertModuleOp { - #[prost(message, optional, tag = "1")] - pub module: ::core::option::Option, +impl ::core::fmt::Debug for SetSourceOp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SetSourceOp") + .field("source", &self.source) + .finish() + } } -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct DeleteVariableOp { - #[prost(string, tag = "1")] - pub ident: ::prost::alloc::string::String, +impl SetSourceOp { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.SetSourceOp"; } -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct RenameVariableOp { - #[prost(string, tag = "1")] - pub from: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub to: ::prost::alloc::string::String, +::buffa::impl_default_instance!(SetSourceOp); +impl ::buffa::MessageName for SetSourceOp { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "SetSourceOp"; + const FULL_NAME: &'static str = "project_io.SetSourceOp"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.SetSourceOp"; } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpsertViewOp { - #[prost(uint32, tag = "1")] - pub index: u32, - #[prost(message, optional, tag = "2")] - pub view: ::core::option::Option, +impl ::buffa::Message for SetSourceOp { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.source.is_set() { + ::buffa::types::put_len_delimited_header(1u32, u64::from(__cache.consume_next()), buf); + self.source.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source = ::buffa::MessageField::none(); + } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct DeleteViewOp { - #[prost(uint32, tag = "1")] - pub index: u32, +#[derive(Clone, PartialEq, Default)] +pub struct Project { + /// Field 1: `name` + pub name: ::buffa::alloc::string::String, + /// Field 2: `sim_specs` + pub sim_specs: ::buffa::MessageField>, + /// Field 4: `dimensions` + pub dimensions: ::buffa::alloc::vec::Vec, + /// Field 6: `units` + pub units: ::buffa::alloc::vec::Vec, + /// Field 3: `models` + pub models: ::buffa::alloc::vec::Vec, + /// Field 5: `source` + pub source: ::buffa::MessageField>, } -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SetSourceOp { - #[prost(message, optional, tag = "1")] - pub source: ::core::option::Option, +impl ::core::fmt::Debug for Project { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Project") + .field("name", &self.name) + .field("sim_specs", &self.sim_specs) + .field("dimensions", &self.dimensions) + .field("units", &self.units) + .field("models", &self.models) + .field("source", &self.source) + .finish() + } } -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Project { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub sim_specs: ::core::option::Option, - #[prost(message, repeated, tag = "4")] - pub dimensions: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "6")] - pub units: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "3")] - pub models: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "5")] - pub source: ::core::option::Option, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum SimMethod { - Euler = 0, - RungeKutta4 = 1, - RungeKutta2 = 3, +impl Project { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/project_io.Project"; } -impl SimMethod { - /// String value of the enum field names used in the ProtoBuf definition. +::buffa::impl_default_instance!(Project); +impl ::buffa::MessageName for Project { + const PACKAGE: &'static str = "project_io"; + const NAME: &'static str = "Project"; + const FULL_NAME: &'static str = "project_io.Project"; + const TYPE_URL: &'static str = "type.googleapis.com/project_io.Project"; +} +impl ::buffa::Message for Project { + /// Returns the total encoded size in bytes. /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Euler => "EULER", - Self::RungeKutta4 => "RUNGE_KUTTA_4", - Self::RungeKutta2 => "RUNGE_KUTTA_2", + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if !self.name.is_empty() { + size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64; + } + if self.sim_specs.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sim_specs.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; } + for v in &self.models { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + for v in &self.dimensions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + if self.source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + for v in &self.units { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size += + 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; + } + ::buffa::saturate_size(size) } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "EULER" => Some(Self::Euler), - "RUNGE_KUTTA_4" => Some(Self::RungeKutta4), - "RUNGE_KUTTA_2" => Some(Self::RungeKutta2), - _ => None, + fn write_to(&self, __cache: &mut ::buffa::SizeCache, buf: &mut impl ::buffa::EncodeSink) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.name.is_empty() { + ::buffa::types::put_string_field(1u32, &self.name, buf); + } + if self.sim_specs.is_set() { + ::buffa::types::put_len_delimited_header(2u32, u64::from(__cache.consume_next()), buf); + self.sim_specs.write_to(__cache, buf); + } + for v in &self.models { + ::buffa::types::put_len_delimited_header(3u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + for v in &self.dimensions { + ::buffa::types::put_len_delimited_header(4u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + if self.source.is_set() { + ::buffa::types::put_len_delimited_header(5u32, u64::from(__cache.consume_next()), buf); + self.source.write_to(__cache, buf); + } + for v in &self.units { + ::buffa::types::put_len_delimited_header(6u32, u64::from(__cache.consume_next()), buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.sim_specs.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.models.push(elem); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.dimensions.push(elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory(::buffa::__private::element_footprint(&elem))?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.units.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.name.clear(); + self.sim_specs = ::buffa::MessageField::none(); + self.models.clear(); + self.dimensions.clear(); + self.source = ::buffa::MessageField::none(); + self.units.clear(); + } +} +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod oneof { + #[allow(unused_imports)] + use super::*; + pub mod variable { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum V { + Stock(super::super::super::variable::Stock), + Flow(super::super::super::variable::Flow), + Aux(super::super::super::variable::Aux), + Module(super::super::super::variable::Module), + } + impl ::buffa::Oneof for V {} + impl From for V { + fn from(v: super::super::super::variable::Stock) -> Self { + Self::Stock(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::variable::Stock) -> Self { + Self::Some(V::from(v)) + } + } + impl From for V { + fn from(v: super::super::super::variable::Flow) -> Self { + Self::Flow(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::variable::Flow) -> Self { + Self::Some(V::from(v)) + } + } + impl From for V { + fn from(v: super::super::super::variable::Aux) -> Self { + Self::Aux(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::variable::Aux) -> Self { + Self::Some(V::from(v)) + } + } + impl From for V { + fn from(v: super::super::super::variable::Module) -> Self { + Self::Module(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::variable::Module) -> Self { + Self::Some(V::from(v)) + } + } + pub mod equation { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum Equation { + Scalar(super::super::super::super::variable::ScalarEquation), + ApplyToAll(super::super::super::super::variable::ApplyToAllEquation), + Arrayed(super::super::super::super::variable::ArrayedEquation), + } + impl ::buffa::Oneof for Equation {} + impl From for Equation { + fn from(v: super::super::super::super::variable::ScalarEquation) -> Self { + Self::Scalar(v) + } + } + impl From + for ::core::option::Option + { + fn from(v: super::super::super::super::variable::ScalarEquation) -> Self { + Self::Some(Equation::from(v)) + } + } + impl From for Equation { + fn from(v: super::super::super::super::variable::ApplyToAllEquation) -> Self { + Self::ApplyToAll(v) + } + } + impl From + for ::core::option::Option + { + fn from(v: super::super::super::super::variable::ApplyToAllEquation) -> Self { + Self::Some(Equation::from(v)) + } + } + impl From for Equation { + fn from(v: super::super::super::super::variable::ArrayedEquation) -> Self { + Self::Arrayed(v) + } + } + impl From + for ::core::option::Option + { + fn from(v: super::super::super::super::variable::ArrayedEquation) -> Self { + Self::Some(Equation::from(v)) + } + } + } + } + pub mod view_element { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum Element { + Aux(super::super::super::view_element::Aux), + Stock(super::super::super::view_element::Stock), + Flow(super::super::super::view_element::Flow), + Link(super::super::super::view_element::Link), + Module(super::super::super::view_element::Module), + Alias(super::super::super::view_element::Alias), + Cloud(super::super::super::view_element::Cloud), + Group(super::super::super::view_element::Group), + } + impl ::buffa::Oneof for Element {} + impl From for Element { + fn from(v: super::super::super::view_element::Aux) -> Self { + Self::Aux(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Aux) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Stock) -> Self { + Self::Stock(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Stock) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Flow) -> Self { + Self::Flow(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Flow) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Link) -> Self { + Self::Link(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Link) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Module) -> Self { + Self::Module(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Module) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Alias) -> Self { + Self::Alias(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Alias) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Cloud) -> Self { + Self::Cloud(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Cloud) -> Self { + Self::Some(Element::from(v)) + } + } + impl From for Element { + fn from(v: super::super::super::view_element::Group) -> Self { + Self::Group(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::view_element::Group) -> Self { + Self::Some(Element::from(v)) + } + } + pub mod link { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum Shape { + Arc(f64), + IsStraight(bool), + MultiPoint(super::super::super::super::view_element::link::LinkPoints), + } + impl ::buffa::Oneof for Shape {} + impl From for Shape { + fn from(v: super::super::super::super::view_element::link::LinkPoints) -> Self { + Self::MultiPoint(v) + } + } + impl From + for ::core::option::Option + { + fn from(v: super::super::super::super::view_element::link::LinkPoints) -> Self { + Self::Some(Shape::from(v)) + } + } + } + } + pub mod dimension { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum Dimension { + Elements(super::super::super::dimension::DimensionElements), + Size(super::super::super::dimension::DimensionSize), + } + impl ::buffa::Oneof for Dimension {} + impl From for Dimension { + fn from(v: super::super::super::dimension::DimensionElements) -> Self { + Self::Elements(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::dimension::DimensionElements) -> Self { + Self::Some(Dimension::from(v)) + } + } + impl From for Dimension { + fn from(v: super::super::super::dimension::DimensionSize) -> Self { + Self::Size(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::dimension::DimensionSize) -> Self { + Self::Some(Dimension::from(v)) + } + } + } + pub mod project_operation { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum Op { + SetSimSpecs(super::super::super::SetSimSpecsOp), + SetSource(super::super::super::SetSourceOp), + } + impl ::buffa::Oneof for Op {} + impl From for Op { + fn from(v: super::super::super::SetSimSpecsOp) -> Self { + Self::SetSimSpecs(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::SetSimSpecsOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::SetSourceOp) -> Self { + Self::SetSource(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::SetSourceOp) -> Self { + Self::Some(Op::from(v)) + } + } + } + pub mod model_operation { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + #[allow(clippy::large_enum_variant)] + pub enum Op { + UpsertStock(super::super::super::UpsertStockOp), + UpsertFlow(super::super::super::UpsertFlowOp), + UpsertAux(super::super::super::UpsertAuxOp), + UpsertModule(super::super::super::UpsertModuleOp), + DeleteVariable(super::super::super::DeleteVariableOp), + RenameVariable(super::super::super::RenameVariableOp), + UpsertView(super::super::super::UpsertViewOp), + DeleteView(super::super::super::DeleteViewOp), + UpdateStockFlows(super::super::super::UpdateStockFlowsOp), + } + impl ::buffa::Oneof for Op {} + impl From for Op { + fn from(v: super::super::super::UpsertStockOp) -> Self { + Self::UpsertStock(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UpsertStockOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::UpsertFlowOp) -> Self { + Self::UpsertFlow(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UpsertFlowOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::UpsertAuxOp) -> Self { + Self::UpsertAux(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UpsertAuxOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::UpsertModuleOp) -> Self { + Self::UpsertModule(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UpsertModuleOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::DeleteVariableOp) -> Self { + Self::DeleteVariable(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::DeleteVariableOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::RenameVariableOp) -> Self { + Self::RenameVariable(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::RenameVariableOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::UpsertViewOp) -> Self { + Self::UpsertView(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UpsertViewOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::DeleteViewOp) -> Self { + Self::DeleteView(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::DeleteViewOp) -> Self { + Self::Some(Op::from(v)) + } + } + impl From for Op { + fn from(v: super::super::super::UpdateStockFlowsOp) -> Self { + Self::UpdateStockFlows(v) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UpdateStockFlowsOp) -> Self { + Self::Some(Op::from(v)) + } + } } } } diff --git a/src/simlin-engine/src/project_io.proto b/src/simlin-engine/src/project_io.proto index 8be87ed40..96d5958c0 100644 --- a/src/simlin-engine/src/project_io.proto +++ b/src/simlin-engine/src/project_io.proto @@ -375,8 +375,8 @@ message Model { repeated LoopMetadata loop_metadata = 5; repeated ModelGroup groups = 6; // Present only when this model is a callable macro template. A singular - // proto3 message field is presence-tracked, so prost generates it as - // Option. + // proto3 message field is presence-tracked, so the generated Rust field is a + // `buffa::MessageField` that distinguishes unset from empty. MacroSpec macro_spec = 7; } diff --git a/src/simlin-engine/src/serde.rs b/src/simlin-engine/src/serde.rs index b20d917f2..ced0bebfb 100644 --- a/src/simlin-engine/src/serde.rs +++ b/src/simlin-engine/src/serde.rs @@ -11,6 +11,7 @@ use crate::datamodel::{ StockFlow, Unit, Variable, View, ViewElement, Visibility, view_element, }; use crate::project_io; +use buffa::{EnumValue, MessageField}; /// Repair a pre-#559 2022-era stored identifier so it survives the /// salsa-boundary re-canonicalization unchanged (issue #690). @@ -120,7 +121,11 @@ fn test_sim_method_roundtrip() { // protobuf enums are open, which we should just treat as Euler assert_eq!( SimMethod::Euler, - SimMethod::from(project_io::SimMethod::try_from(666).unwrap_or_default()) + SimMethod::from( + EnumValue::::from(666) + .as_known() + .unwrap_or_default() + ) ); } @@ -129,9 +134,9 @@ impl From for project_io::SimSpecs { project_io::SimSpecs { start: sim_specs.start, stop: sim_specs.stop, - dt: Some(project_io::Dt::from(sim_specs.dt)), - save_step: sim_specs.save_step.map(project_io::Dt::from), - sim_method: project_io::SimMethod::from(sim_specs.sim_method) as i32, + dt: MessageField::some(project_io::Dt::from(sim_specs.dt)), + save_step: sim_specs.save_step.map(project_io::Dt::from).into(), + sim_method: project_io::SimMethod::from(sim_specs.sim_method).into(), time_units: sim_specs.time_units, } } @@ -142,14 +147,12 @@ impl From for SimSpecs { SimSpecs { start: sim_specs.start, stop: sim_specs.stop, - dt: Dt::from(sim_specs.dt.unwrap_or(project_io::Dt { + dt: Dt::from(sim_specs.dt.into_option().unwrap_or(project_io::Dt { value: 1.0, is_reciprocal: false, })), save_step: sim_specs.save_step.map(Dt::from), - sim_method: SimMethod::from( - project_io::SimMethod::try_from(sim_specs.sim_method).unwrap_or_default(), - ), + sim_method: SimMethod::from(sim_specs.sim_method.as_known().unwrap_or_default()), time_units: sim_specs.time_units.filter(|s| !s.is_empty()), } } @@ -218,7 +221,9 @@ fn test_graphical_function_kind_roundtrip() { assert_eq!( project_io::graphical_function::Kind::Continuous, - project_io::graphical_function::Kind::try_from(666).unwrap_or_default() + EnumValue::::from(666) + .as_known() + .unwrap_or_default() ); } @@ -258,11 +263,11 @@ fn test_graphical_function_scale_roundtrip() { impl From for project_io::GraphicalFunction { fn from(gf: GraphicalFunction) -> Self { project_io::GraphicalFunction { - kind: project_io::graphical_function::Kind::from(gf.kind) as i32, + kind: project_io::graphical_function::Kind::from(gf.kind).into(), x_points: gf.x_points.unwrap_or_default(), y_points: gf.y_points, - x_scale: Some(project_io::graphical_function::Scale::from(gf.x_scale)), - y_scale: Some(project_io::graphical_function::Scale::from(gf.y_scale)), + x_scale: MessageField::some(project_io::graphical_function::Scale::from(gf.x_scale)), + y_scale: MessageField::some(project_io::graphical_function::Scale::from(gf.y_scale)), } } } @@ -270,9 +275,7 @@ impl From for project_io::GraphicalFunction { impl From for GraphicalFunction { fn from(gf: project_io::GraphicalFunction) -> Self { GraphicalFunction { - kind: GraphicalFunctionKind::from( - project_io::graphical_function::Kind::try_from(gf.kind).unwrap_or_default(), - ), + kind: GraphicalFunctionKind::from(gf.kind.as_known().unwrap_or_default()), x_points: if gf.x_points.is_empty() { None } else { @@ -318,7 +321,7 @@ fn data_source_to_proto(ds: &DataSource) -> project_io::variable::DataSource { DataSourceKind::Subscript => project_io::variable::data_source::Kind::Subscript, }; project_io::variable::DataSource { - kind: kind as i32, + kind: kind.into(), file: ds.file.clone(), tab_or_delimiter: ds.tab_or_delimiter.clone(), row_or_col: ds.row_or_col.clone(), @@ -327,12 +330,12 @@ fn data_source_to_proto(ds: &DataSource) -> project_io::variable::DataSource { } fn data_source_from_proto(ds: project_io::variable::DataSource) -> DataSource { - let kind = match project_io::variable::data_source::Kind::try_from(ds.kind) { - Ok(project_io::variable::data_source::Kind::Data) => DataSourceKind::Data, - Ok(project_io::variable::data_source::Kind::Constants) => DataSourceKind::Constants, - Ok(project_io::variable::data_source::Kind::Lookups) => DataSourceKind::Lookups, - Ok(project_io::variable::data_source::Kind::Subscript) => DataSourceKind::Subscript, - Err(_) => DataSourceKind::Data, + let kind = match ds.kind.as_known() { + Some(project_io::variable::data_source::Kind::Data) => DataSourceKind::Data, + Some(project_io::variable::data_source::Kind::Constants) => DataSourceKind::Constants, + Some(project_io::variable::data_source::Kind::Lookups) => DataSourceKind::Lookups, + Some(project_io::variable::data_source::Kind::Subscript) => DataSourceKind::Subscript, + None => DataSourceKind::Data, }; DataSource { kind, @@ -402,7 +405,7 @@ fn spreadflow_to_proto(s: &SpreadFlow) -> project_io::variable::SpreadFlow { Source => (Method::Source, None), }; project_io::variable::SpreadFlow { - method: method as i32, + method: method.into(), distrib_eq, } } @@ -410,7 +413,7 @@ fn spreadflow_to_proto(s: &SpreadFlow) -> project_io::variable::SpreadFlow { fn spreadflow_from_proto(s: project_io::variable::SpreadFlow) -> SpreadFlow { use SpreadFlow::*; use project_io::variable::spread_flow::Method; - match Method::try_from(s.method).unwrap_or(Method::Beginning) { + match s.method.as_known().unwrap_or(Method::Beginning) { Method::Beginning => Beginning, Method::Even => Even, Method::Dest => Dest, @@ -436,37 +439,34 @@ fn compat_to_proto(compat: &Compat) -> Option { active_initial: compat.active_initial.clone(), non_negative: Some(compat.non_negative), can_be_module_input: Some(compat.can_be_module_input), - visibility: Some(project_io::variable::Visibility::from(compat.visibility) as i32), - data_source: compat.data_source.as_ref().map(data_source_to_proto), - conveyor: compat.conveyor.as_ref().map(conveyor_to_proto), - leakage: compat.leakage.as_ref().map(leakage_to_proto), - spreadflow: compat.spreadflow.as_ref().map(spreadflow_to_proto), - queue: compat.queue.as_ref().map(queue_to_proto), + visibility: Some(project_io::variable::Visibility::from(compat.visibility).into()), + data_source: compat.data_source.as_ref().map(data_source_to_proto).into(), + conveyor: compat.conveyor.as_ref().map(conveyor_to_proto).into(), + leakage: compat.leakage.as_ref().map(leakage_to_proto).into(), + spreadflow: compat.spreadflow.as_ref().map(spreadflow_to_proto).into(), + queue: compat.queue.as_ref().map(queue_to_proto).into(), overflow: compat.overflow, }) } fn compat_from_proto( - proto_compat: Option, + proto_compat: impl Into>, legacy_ai: Option, legacy_nn: bool, legacy_cbmi: bool, - legacy_vis: i32, + legacy_vis: EnumValue, ) -> Compat { - match proto_compat { + let legacy_vis = Visibility::from(legacy_vis.as_known().unwrap_or_default()); + match proto_compat.into() { Some(c) => Compat { active_initial: c.active_initial.or(legacy_ai), non_negative: c.non_negative.unwrap_or(legacy_nn), can_be_module_input: c.can_be_module_input.unwrap_or(legacy_cbmi), visibility: c .visibility - .and_then(|v| project_io::variable::Visibility::try_from(v).ok()) + .and_then(|v| v.as_known()) .map(Visibility::from) - .unwrap_or_else(|| { - Visibility::from( - project_io::variable::Visibility::try_from(legacy_vis).unwrap_or_default(), - ) - }), + .unwrap_or(legacy_vis), data_source: c.data_source.map(data_source_from_proto), conveyor: c.conveyor.map(conveyor_from_proto), leakage: c.leakage.map(leakage_from_proto), @@ -478,9 +478,7 @@ fn compat_from_proto( active_initial: legacy_ai, non_negative: legacy_nn, can_be_module_input: legacy_cbmi, - visibility: Visibility::from( - project_io::variable::Visibility::try_from(legacy_vis).unwrap_or_default(), - ), + visibility: legacy_vis, data_source: None, conveyor: None, leakage: None, @@ -521,7 +519,7 @@ impl From for project_io::variable::Equation { subscript, equation, initial_equation, - gf: gf.map(project_io::GraphicalFunction::from), + gf: gf.map(project_io::GraphicalFunction::from).into(), } }) .collect(), @@ -669,13 +667,13 @@ fn arrayed_element_subscripts_deserialize_to_the_canonical_key() { subscript: "NYC, Young".to_string(), equation: "100".to_string(), initial_equation: None, - gf: None, + gf: MessageField::none(), }, project_io::variable::arrayed_equation::Element { subscript: " boston ,old".to_string(), equation: "80".to_string(), initial_equation: None, - gf: None, + gf: MessageField::none(), }, ], default_equation: None, @@ -700,7 +698,7 @@ fn test_has_except_default_absent_defaults_to_false() { subscript: "a1".to_string(), equation: "5".to_string(), initial_equation: None, - gf: None, + gf: MessageField::none(), }], has_except_default: None, default_equation: None, @@ -728,7 +726,7 @@ fn test_legacy_proto_with_default_equation_infers_has_except() { subscript: "a1".to_string(), equation: "5".to_string(), initial_equation: None, - gf: None, + gf: MessageField::none(), }], has_except_default: None, default_equation: Some("10".to_string()), @@ -796,7 +794,9 @@ fn test_visibility_roundtrip() { assert_eq!( project_io::variable::Visibility::Private, - project_io::variable::Visibility::try_from(666).unwrap_or_default() + EnumValue::::from(666) + .as_known() + .unwrap_or_default() ); } @@ -805,16 +805,16 @@ impl From for project_io::variable::Stock { let compat = compat_to_proto(&stock.compat); project_io::variable::Stock { ident: stock.ident, - equation: Some(stock.equation.into()), + equation: MessageField::some(stock.equation.into()), documentation: stock.documentation, units: stock.units.unwrap_or_default(), inflows: stock.inflows, outflows: stock.outflows, non_negative: stock.compat.non_negative, can_be_module_input: stock.compat.can_be_module_input, - visibility: project_io::variable::Visibility::from(stock.compat.visibility) as i32, + visibility: project_io::variable::Visibility::from(stock.compat.visibility).into(), uid: stock.uid.unwrap_or_default(), - compat, + compat: compat.into(), } } } @@ -823,7 +823,7 @@ impl From for Stock { fn from(stock: project_io::variable::Stock) -> Self { let legacy_ai = stock .equation - .as_ref() + .as_option() .and_then(extract_legacy_initial_equation); let compat = compat_from_proto( stock.compat, @@ -923,17 +923,14 @@ fn test_stock_proto_legacy_fields_populated() { let proto = project_io::variable::Stock::from(stock); assert!(proto.non_negative); assert!(proto.can_be_module_input); - assert_eq!( - proto.visibility, - project_io::variable::Visibility::Public as i32 - ); + assert_eq!(proto.visibility, project_io::variable::Visibility::Public); } #[test] fn test_stock_proto_legacy_only_deserialization() { let proto = project_io::variable::Stock { ident: "pop".to_string(), - equation: Some(project_io::variable::Equation { + equation: MessageField::some(project_io::variable::Equation { equation: Some(project_io::variable::equation::Equation::Scalar( project_io::variable::ScalarEquation { equation: "100".to_string(), @@ -947,9 +944,9 @@ fn test_stock_proto_legacy_only_deserialization() { outflows: vec![], non_negative: true, can_be_module_input: true, - visibility: project_io::variable::Visibility::Public as i32, + visibility: project_io::variable::Visibility::Public.into(), uid: 0, - compat: None, + compat: MessageField::none(), }; let stock = Stock::from(proto); assert!(stock.compat.non_negative); @@ -1011,15 +1008,15 @@ impl From for project_io::variable::Flow { let compat = compat_to_proto(&flow.compat); project_io::variable::Flow { ident: flow.ident, - equation: Some(flow.equation.into()), + equation: MessageField::some(flow.equation.into()), documentation: flow.documentation, units: flow.units.unwrap_or_default(), - gf: flow.gf.map(project_io::GraphicalFunction::from), + gf: flow.gf.map(project_io::GraphicalFunction::from).into(), non_negative: flow.compat.non_negative, can_be_module_input: flow.compat.can_be_module_input, - visibility: project_io::variable::Visibility::from(flow.compat.visibility) as i32, + visibility: project_io::variable::Visibility::from(flow.compat.visibility).into(), uid: flow.uid.unwrap_or_default(), - compat, + compat: compat.into(), } } } @@ -1028,7 +1025,7 @@ impl From for Flow { fn from(flow: project_io::variable::Flow) -> Self { let legacy_ai = flow .equation - .as_ref() + .as_option() .and_then(extract_legacy_initial_equation); let compat = compat_from_proto( flow.compat, @@ -1111,14 +1108,14 @@ impl From for project_io::variable::Aux { let compat = compat_to_proto(&aux.compat); project_io::variable::Aux { ident: aux.ident, - equation: Some(aux.equation.into()), + equation: MessageField::some(aux.equation.into()), documentation: aux.documentation, units: aux.units.unwrap_or_default(), - gf: aux.gf.map(project_io::GraphicalFunction::from), + gf: aux.gf.map(project_io::GraphicalFunction::from).into(), can_be_module_input: aux.compat.can_be_module_input, - visibility: project_io::variable::Visibility::from(aux.compat.visibility) as i32, + visibility: project_io::variable::Visibility::from(aux.compat.visibility).into(), uid: aux.uid.unwrap_or_default(), - compat, + compat: compat.into(), } } } @@ -1127,7 +1124,7 @@ impl From for Aux { fn from(aux: project_io::variable::Aux) -> Self { let legacy_ai = aux .equation - .as_ref() + .as_option() .and_then(extract_legacy_initial_equation); let compat = compat_from_proto( aux.compat, @@ -1217,7 +1214,7 @@ fn test_aux_roundtrip() { fn test_aux_ident_literal_period_migrated_on_deserialize() { let proto = project_io::variable::Aux { ident: "goal_1.5_for_temperature".to_string(), - equation: Some(project_io::variable::Equation { + equation: MessageField::some(project_io::variable::Equation { equation: Some(project_io::variable::equation::Equation::Scalar( project_io::variable::ScalarEquation { equation: "1.5".to_string(), @@ -1289,7 +1286,7 @@ fn test_equation_dimension_and_subscript_references_migrated_on_deserialize() { subscript: "elem_1.5".to_string(), equation: "1.5".to_string(), initial_equation: None, - gf: None, + gf: MessageField::none(), }], has_except_default: None, default_equation: None, @@ -1355,9 +1352,9 @@ impl From for project_io::variable::Module { .map(project_io::variable::module::Reference::from) .collect(), can_be_module_input: module.compat.can_be_module_input, - visibility: project_io::variable::Visibility::from(module.compat.visibility) as i32, + visibility: project_io::variable::Visibility::from(module.compat.visibility).into(), uid: module.uid.unwrap_or_default(), - compat, + compat: compat.into(), } } } @@ -1549,7 +1546,9 @@ fn test_label_side_roundtrip() { assert_eq!( project_io::view_element::LabelSide::Top, - project_io::view_element::LabelSide::try_from(666).unwrap_or_default() + EnumValue::::from(666) + .as_known() + .unwrap_or_default() ); } @@ -1566,9 +1565,9 @@ fn view_compat_to_proto( } fn view_compat_from_proto( - compat: Option, + compat: impl Into>, ) -> Option { - compat.and_then(|c| { + compat.into().and_then(|c| { // Only produce Some if at least one field was explicitly set, // otherwise treat a default-valued proto message as absent. if c.width.is_none() && c.height.is_none() && c.bits.is_none() { @@ -1592,9 +1591,7 @@ impl From for view_element::Aux { uid: v.uid, x: v.x, y: v.y, - label_side: view_element::LabelSide::from( - project_io::view_element::LabelSide::try_from(v.label_side).unwrap_or_default(), - ), + label_side: view_element::LabelSide::from(v.label_side.as_known().unwrap_or_default()), compat: view_compat_from_proto(v.compat), } } @@ -1607,8 +1604,8 @@ impl From for project_io::view_element::Aux { uid: v.uid, x: v.x, y: v.y, - label_side: project_io::view_element::LabelSide::from(v.label_side) as i32, - compat: view_compat_to_proto(&v.compat), + label_side: project_io::view_element::LabelSide::from(v.label_side).into(), + compat: view_compat_to_proto(&v.compat).into(), } } } @@ -1637,9 +1634,7 @@ impl From for view_element::Stock { uid: v.uid, x: v.x, y: v.y, - label_side: view_element::LabelSide::from( - project_io::view_element::LabelSide::try_from(v.label_side).unwrap_or_default(), - ), + label_side: view_element::LabelSide::from(v.label_side.as_known().unwrap_or_default()), compat: view_compat_from_proto(v.compat), } } @@ -1652,8 +1647,8 @@ impl From for project_io::view_element::Stock { uid: v.uid, x: v.x, y: v.y, - label_side: project_io::view_element::LabelSide::from(v.label_side) as i32, - compat: view_compat_to_proto(&v.compat), + label_side: project_io::view_element::LabelSide::from(v.label_side).into(), + compat: view_compat_to_proto(&v.compat).into(), } } } @@ -1767,9 +1762,7 @@ impl From for view_element::Flow { uid: v.uid, x: v.x, y: v.y, - label_side: view_element::LabelSide::from( - project_io::view_element::LabelSide::try_from(v.label_side).unwrap_or_default(), - ), + label_side: view_element::LabelSide::from(v.label_side.as_known().unwrap_or_default()), points: v .points .into_iter() @@ -1788,14 +1781,14 @@ impl From for project_io::view_element::Flow { uid: v.uid, x: v.x, y: v.y, - label_side: project_io::view_element::LabelSide::from(v.label_side) as i32, + label_side: project_io::view_element::LabelSide::from(v.label_side).into(), points: v .points .into_iter() .map(project_io::view_element::FlowPoint::from) .collect(), - compat: view_compat_to_proto(&v.compat), - label_compat: view_compat_to_proto(&v.label_compat), + compat: view_compat_to_proto(&v.compat).into(), + label_compat: view_compat_to_proto(&v.label_compat).into(), } } } @@ -1833,7 +1826,7 @@ fn test_view_element_flow_roundtrip() { impl From for view_element::Link { fn from(v: project_io::view_element::Link) -> Self { - let polarity = match v.polarity() { + let polarity = match v.polarity.as_known().unwrap_or_default() { project_io::view_element::link::Polarity::Positive => { Some(view_element::LinkPolarity::Positive) } @@ -1875,12 +1868,12 @@ impl From for project_io::view_element::Link { fn from(v: view_element::Link) -> Self { let polarity = match v.polarity { Some(view_element::LinkPolarity::Positive) => { - project_io::view_element::link::Polarity::Positive as i32 + project_io::view_element::link::Polarity::Positive } Some(view_element::LinkPolarity::Negative) => { - project_io::view_element::link::Polarity::Negative as i32 + project_io::view_element::link::Polarity::Negative } - None => project_io::view_element::link::Polarity::Unspecified as i32, + None => project_io::view_element::link::Polarity::Unspecified, }; project_io::view_element::Link { uid: v.uid, @@ -1904,7 +1897,7 @@ impl From for project_io::view_element::Link { )) } }, - polarity, + polarity: polarity.into(), } } } @@ -1960,9 +1953,7 @@ impl From for view_element::Module { uid: v.uid, x: v.x, y: v.y, - label_side: view_element::LabelSide::from( - project_io::view_element::LabelSide::try_from(v.label_side).unwrap_or_default(), - ), + label_side: view_element::LabelSide::from(v.label_side.as_known().unwrap_or_default()), } } } @@ -1974,7 +1965,7 @@ impl From for project_io::view_element::Module { uid: v.uid, x: v.x, y: v.y, - label_side: project_io::view_element::LabelSide::from(v.label_side) as i32, + label_side: project_io::view_element::LabelSide::from(v.label_side).into(), } } } @@ -2003,9 +1994,7 @@ impl From for view_element::Alias { alias_of_uid: v.alias_of_uid, x: v.x, y: v.y, - label_side: view_element::LabelSide::from( - project_io::view_element::LabelSide::try_from(v.label_side).unwrap_or_default(), - ), + label_side: view_element::LabelSide::from(v.label_side.as_known().unwrap_or_default()), compat: view_compat_from_proto(v.compat), } } @@ -2018,8 +2007,8 @@ impl From for project_io::view_element::Alias { alias_of_uid: v.alias_of_uid, x: v.x, y: v.y, - label_side: project_io::view_element::LabelSide::from(v.label_side) as i32, - compat: view_compat_to_proto(&v.compat), + label_side: project_io::view_element::LabelSide::from(v.label_side).into(), + compat: view_compat_to_proto(&v.compat).into(), } } } @@ -2061,7 +2050,7 @@ impl From for project_io::view_element::Cloud { flow_uid: v.flow_uid, x: v.x, y: v.y, - compat: view_compat_to_proto(&v.compat), + compat: view_compat_to_proto(&v.compat).into(), } } } @@ -2212,13 +2201,13 @@ impl From for project_io::View { }; project_io::View { - kind: project_io::view::ViewType::StockFlow as i32, + kind: project_io::view::ViewType::StockFlow.into(), elements: view .elements .into_iter() .map(project_io::ViewElement::from) .collect(), - view_box: Some(view.view_box.into()), + view_box: MessageField::some(view.view_box.into()), zoom: view.zoom, use_lettered_polarity: view.use_lettered_polarity, name, @@ -2304,9 +2293,9 @@ fn test_view_roundtrip_preserves_absent_title() { #[test] fn test_view_deserialize_keeps_nonempty_name_without_presence_flag() { let proto = project_io::View { - kind: project_io::view::ViewType::StockFlow as i32, + kind: project_io::view::ViewType::StockFlow.into(), elements: vec![], - view_box: Some(project_io::Rect::from(Rect::default())), + view_box: MessageField::some(project_io::Rect::from(Rect::default())), zoom: 1.0, use_lettered_polarity: false, name: "Overview".to_string(), @@ -2353,7 +2342,7 @@ impl From for project_io::Model { .into_iter() .map(project_io::ModelGroup::from) .collect(), - macro_spec: model.macro_spec.map(project_io::MacroSpec::from), + macro_spec: model.macro_spec.map(project_io::MacroSpec::from).into(), } } } @@ -2782,9 +2771,7 @@ impl From for project_io::Source { impl From for Source { fn from(source: project_io::Source) -> Self { Source { - extension: project_io::source::Extension::try_from(source.extension) - .unwrap_or_default() - .into(), + extension: source.extension.as_known().unwrap_or_default().into(), content: source.content, } } @@ -2820,7 +2807,7 @@ impl From for project_io::Project { fn from(project: Project) -> Self { project_io::Project { name: project.name, - sim_specs: Some(project_io::SimSpecs::from(project.sim_specs)), + sim_specs: MessageField::some(project_io::SimSpecs::from(project.sim_specs)), dimensions: project .dimensions .into_iter() @@ -2836,7 +2823,7 @@ impl From for project_io::Project { .into_iter() .map(project_io::Model::from) .collect(), - source: project.source.map(|source| source.into()), + source: project.source.map(project_io::Source::from).into(), } } } @@ -3270,7 +3257,7 @@ fn test_protobuf_backward_compat_old_protos() { subscript: "a1".to_string(), equation: "5".to_string(), initial_equation: None, - gf: None, + gf: MessageField::none(), }], has_except_default: None, default_equation: None, @@ -3291,15 +3278,15 @@ fn test_protobuf_backward_compat_old_protos() { active_initial: Some("init".to_string()), non_negative: Some(true), can_be_module_input: Some(false), - visibility: Some(0), - data_source: None, - conveyor: None, - leakage: None, - spreadflow: None, - queue: None, + visibility: Some(0.into()), + data_source: MessageField::none(), + conveyor: MessageField::none(), + leakage: MessageField::none(), + spreadflow: MessageField::none(), + queue: MessageField::none(), overflow: false, }; - let compat = compat_from_proto(Some(old_compat), None, false, false, 0); + let compat = compat_from_proto(Some(old_compat), None, false, false, 0.into()); assert_eq!(compat.data_source, None); assert_eq!(compat.active_initial, Some("init".to_string())); diff --git a/src/simlin-engine/tests/integration/json_roundtrip.rs b/src/simlin-engine/tests/integration/json_roundtrip.rs index c3bf640a1..18a142ecd 100644 --- a/src/simlin-engine/tests/integration/json_roundtrip.rs +++ b/src/simlin-engine/tests/integration/json_roundtrip.rs @@ -14,7 +14,7 @@ use std::fs::File; use std::io::BufReader; -use simlin_engine::prost::Message; +use simlin_engine::buffa::Message; use simlin_engine::xmile; use simlin_engine::{datamodel, json, project_io, serde as project_serde}; @@ -23,11 +23,10 @@ use simlin_engine::{datamodel, json, project_io, serde as project_serde}; fn roundtrip_to_json(dm: &datamodel::Project) -> (Vec, String) { // datamodel -> protobuf -> bytes let pb: project_io::Project = project_serde::serialize(dm).unwrap(); - let mut pb_bytes = Vec::new(); - pb.encode(&mut pb_bytes).unwrap(); + let pb_bytes = pb.encode_to_vec(); // bytes -> protobuf -> datamodel -> JSON - let pb_decoded = project_io::Project::decode(&pb_bytes[..]).unwrap(); + let pb_decoded = project_io::Project::decode_from_slice(&pb_bytes).unwrap(); let dm_decoded: datamodel::Project = project_serde::deserialize(pb_decoded); let json_project: json::Project = dm_decoded.into(); let json_str = serde_json::to_string(&json_project).unwrap(); diff --git a/src/simlin-engine/tests/integration/layout.rs b/src/simlin-engine/tests/integration/layout.rs index 096890900..8d87f6b93 100644 --- a/src/simlin-engine/tests/integration/layout.rs +++ b/src/simlin-engine/tests/integration/layout.rs @@ -2466,9 +2466,9 @@ fn test_flow_endpoints_geometrically_attached_to_stocks() { /// attribute is normalized to a space on read, silently losing the break. #[test] fn test_incremental_two_word_label_round_trips_every_format() { + use simlin_engine::buffa::Message; use simlin_engine::datamodel; use simlin_engine::layout::incremental_layout; - use simlin_engine::prost::Message; use simlin_engine::{ModelOperation, ModelPatch, json, project_io, serde as project_serde}; let project = load_project("test/test-models/samples/teacup/teacup_w_diagram.xmile"); @@ -2531,9 +2531,9 @@ fn test_incremental_two_word_label_round_trips_every_format() { // protobuf let pb: project_io::Project = project_serde::serialize(&patched).unwrap(); - let mut bytes = Vec::new(); - pb.encode(&mut bytes).unwrap(); - let from_pb = project_serde::deserialize(project_io::Project::decode(&bytes[..]).unwrap()); + let bytes = pb.encode_to_vec(); + let from_pb = + project_serde::deserialize(project_io::Project::decode_from_slice(&bytes).unwrap()); assert_eq!( label_of(&first_view(&from_pb)), laid_out, diff --git a/src/simlin-engine/tests/integration/simulate.rs b/src/simlin-engine/tests/integration/simulate.rs index 5778eaf7e..1089dac38 100644 --- a/src/simlin-engine/tests/integration/simulate.rs +++ b/src/simlin-engine/tests/integration/simulate.rs @@ -1905,14 +1905,11 @@ fn simulate_path_with_excluding(xmile_path: &str, compile: CompileFn, excluded: // datamodel equality (the reader legitimately normalizes), so simulating // the re-read project is the only thing that pins its behaviour. { - use simlin_engine::prost::Message; + use simlin_engine::buffa::Message; - let pb_project_inner = serialize(&datamodel_project).unwrap(); - let pb_project = &pb_project_inner; - let mut buf = Vec::with_capacity(pb_project.encoded_len()); - pb_project.encode(&mut buf).unwrap(); + let buf = serialize(&datamodel_project).unwrap().encode_to_vec(); - let datamodel_project2 = deserialize(project_io::Project::decode(&*buf).unwrap()); + let datamodel_project2 = deserialize(project_io::Project::decode_from_slice(&buf).unwrap()); assert_eq!(datamodel_project, datamodel_project2); } @@ -2046,12 +2043,10 @@ fn simulate_special_path(xmile_path: &str) { // must survive serialization, or the re-compiled model silently loses its // pass and drains as an ordinary stock. let datamodel_proto = { - use simlin_engine::prost::Message; + use simlin_engine::buffa::Message; - let pb_project = serialize(&datamodel_project).unwrap(); - let mut buf = Vec::with_capacity(pb_project.encoded_len()); - pb_project.encode(&mut buf).unwrap(); - deserialize(project_io::Project::decode(&*buf).unwrap()) + let buf = serialize(&datamodel_project).unwrap().encode_to_vec(); + deserialize(project_io::Project::decode_from_slice(&buf).unwrap()) }; assert_eq!(datamodel_project, datamodel_proto); ensure_results(&baseline, &vm_results_for_special(&datamodel_proto, "main")); @@ -5308,7 +5303,7 @@ fn mark2_mdl_compiles_incrementally() { /// import and simulation. #[test] fn mark2_mdl_compiles_after_protobuf_roundtrip() { - use prost::Message; + use buffa::Message; let contents = std::fs::read_to_string("../../test/bobby/vdf/econ/mark2.mdl").expect("read mark2.mdl"); @@ -5316,11 +5311,10 @@ fn mark2_mdl_compiles_after_protobuf_roundtrip() { // Serialize to protobuf (as the app does in NewProject.tsx) let pb = serialize(&project).expect("serialize to protobuf"); - let mut buf = Vec::new(); - pb.encode(&mut buf).expect("encode protobuf"); + let buf = pb.encode_to_vec(); // Deserialize from protobuf (as the app does when loading from storage) - let pb2 = project_io::Project::decode(buf.as_slice()).expect("decode protobuf"); + let pb2 = project_io::Project::decode_from_slice(&buf).expect("decode protobuf"); let project2 = deserialize(pb2); // Compile the round-tripped project