diff --git a/Cargo.lock b/Cargo.lock index ad04b8a1a4..b08783920d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ dependencies = [ "actix-rt", "actix-service", "actix-utils", - "ahash", + "ahash 0.8.3", "base64", "bitflags 2.4.0", "bytes", @@ -71,7 +71,7 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rand", + "rand 0.8.5", "sha1", "smallvec", "tokio", @@ -165,7 +165,7 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash", + "ahash 0.8.3", "bytes", "bytestring", "cfg-if", @@ -245,6 +245,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom 0.2.10", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.3" @@ -252,7 +263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -278,6 +289,63 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7d0a018de4f6aa429b9d33d69edf69072b1c5b1cb8d3e4a5f7ef898fc3eb76" +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "askama" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb98f10f371286b177db5eeb9a6e5396609555686a35e1d4f7b9a9c6d8af0139" +dependencies = [ + "askama_derive", + "askama_escape", + "askama_shared", +] + +[[package]] +name = "askama_derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87bf87e6e8b47264efa9bde63d6225c6276a52e05e91bf37eaa8afd0032d6b71" +dependencies = [ + "askama_shared", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "askama_escape" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" + +[[package]] +name = "askama_shared" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf722b94118a07fcbc6640190f247334027685d4e218b794dbfe17c32bf38ed0" +dependencies = [ + "askama_escape", + "humansize", + "mime", + "mime_guess", + "nom", + "num-traits", + "percent-encoding", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "toml", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -317,7 +385,7 @@ dependencies = [ "log", "parking", "polling", - "rustix", + "rustix 0.37.23", "slab", "socket2 0.4.9", "waker-fn", @@ -402,6 +470,27 @@ version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -511,7 +600,7 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "bitflags 1.3.2", "clap_lex", - "indexmap", + "indexmap 1.9.3", "textwrap", ] @@ -524,6 +613,25 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" +dependencies = [ + "codespan-reporting", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "concurrent-queue" version = "2.2.0" @@ -627,6 +735,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -656,6 +770,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.10.7" @@ -666,12 +786,42 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "ena" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +dependencies = [ + "log", +] + [[package]] name = "encoding_rs" version = "0.8.33" @@ -694,6 +844,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.3" @@ -732,6 +888,16 @@ dependencies = [ "smallvec", ] +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -741,6 +907,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fnv" version = "1.0.7" @@ -826,6 +998,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.10" @@ -834,7 +1017,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -867,6 +1050,15 @@ version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74721d007512d0cb3338cd20f0654ac913920061a4c4d0d8708edb3f2a698c0c" +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.7", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -879,9 +1071,21 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash", + "ahash 0.8.3", ] +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -920,6 +1124,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humansize" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" + [[package]] name = "humantime" version = "2.1.0" @@ -936,6 +1146,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "1.9.3" @@ -946,6 +1162,16 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "indexmap" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +dependencies = [ + "equivalent", + "hashbrown 0.14.2", +] + [[package]] name = "instant" version = "0.1.12" @@ -966,6 +1192,17 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi 0.3.2", + "rustix 0.38.13", + "windows-sys", +] + [[package]] name = "itertools" version = "0.10.5" @@ -990,6 +1227,38 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lalrpop" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" +dependencies = [ + "ascii-canvas", + "bit-set", + "diff", + "ena", + "is-terminal", + "itertools", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax 0.7.5", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" +dependencies = [ + "regex", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -1014,6 +1283,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" + [[package]] name = "local-channel" version = "0.1.3" @@ -1049,6 +1324,29 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "logos" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c" +dependencies = [ + "beef", + "fnv", + "proc-macro2", + "quote", + "regex-syntax 0.6.29", + "syn 1.0.109", +] + [[package]] name = "lru" version = "0.8.1" @@ -1095,6 +1393,12 @@ dependencies = [ [[package]] name = "mediasoup-sys" version = "0.6.0" +dependencies = [ + "planus", + "planus-codegen", + "planus-translation", + "serde", +] [[package]] name = "memchr" @@ -1117,6 +1421,22 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1134,16 +1454,32 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nohash-hasher" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "num-traits" version = "0.2.16" @@ -1275,6 +1611,31 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.2", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1297,6 +1658,64 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "planus-codegen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52d1bb11066c61d46d6d8f21d342d300f06d08bcce15f88399fdd40e1341c421" +dependencies = [ + "askama", + "eyre", + "heck", + "planus-types", + "random_color", + "thiserror", + "vec_map", +] + +[[package]] +name = "planus-lexer" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ecb00082b1324541f02f323585333e88ed3bf90cdbad3741e52eabf166fbcd6" +dependencies = [ + "codespan", + "derive_more", + "logos", +] + +[[package]] +name = "planus-translation" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7bd8ffea859844a23ea28d58354e9e466f3454981b368ba7d8226edac50398b" +dependencies = [ + "atty", + "bitflags 2.4.0", + "codespan", + "codespan-reporting", + "indexmap 1.9.3", + "lalrpop", + "lalrpop-util", + "num-traits", + "planus-lexer", + "planus-types", + "string-interner", +] + +[[package]] +name = "planus-types" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10306bda3579cc7a43537cb3f81212d93ce4fea32a219d9c0a7788d8c5d8e114" +dependencies = [ + "codespan", + "indexmap 1.9.3", + "lalrpop-util", + "planus-lexer", + "string-interner", +] + [[package]] name = "plotters" version = "0.3.5" @@ -1347,7 +1766,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9" dependencies = [ - "rand", + "rand 0.8.5", ] [[package]] @@ -1356,6 +1775,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -1380,6 +1805,20 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + [[package]] name = "rand" version = "0.8.5" @@ -1387,8 +1826,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -1398,7 +1847,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -1407,7 +1865,34 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.10", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "random_color" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f34bd6526786b2ce5141fd37a4084b5da1ebae74595b5b0d05482a7cef7181" +dependencies = [ + "rand 0.7.3", ] [[package]] @@ -1450,6 +1935,17 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.10", + "redox_syscall 0.2.16", + "thiserror", +] + [[package]] name = "regex" version = "1.9.5" @@ -1459,7 +1955,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax", + "regex-syntax 0.7.5", ] [[package]] @@ -1470,9 +1966,15 @@ checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.5" @@ -1504,10 +2006,29 @@ dependencies = [ "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.8", "windows-sys", ] +[[package]] +name = "rustix" +version = "0.38.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.10", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.15" @@ -1537,18 +2058,18 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -1609,6 +2130,12 @@ dependencies = [ "libc", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -1644,6 +2171,30 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "string-interner" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e2531d8525b29b514d25e275a43581320d587b86db302b9a7e464bac579648" +dependencies = [ + "cfg-if", + "hashbrown 0.11.2", + "serde", +] + +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot 0.12.1", + "phf_shared", + "precomputed-hash", +] + [[package]] name = "syn" version = "1.0.109" @@ -1666,6 +2217,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + [[package]] name = "termcolor" version = "1.2.0" @@ -1729,6 +2291,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -1785,6 +2356,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "tracing" version = "0.1.37" @@ -1812,6 +2392,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -1833,6 +2422,18 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "url" version = "2.4.1" @@ -1850,10 +2451,16 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ - "getrandom", + "getrandom 0.2.10", "serde", ] +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.4" @@ -1876,6 +2483,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 01897bb9b8..968b5e3d45 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -59,7 +59,7 @@ version = "1.6.0" [dependencies.serde] features = ["derive"] -version = "1.0.147" +version = "1.0.190" [dependencies.uuid] features = ["serde", "v4"] diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 512165fc26..d1940de235 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -3,7 +3,7 @@ #[cfg(test)] mod tests; -use crate::fbs::{common, rtp_packet, sctp_association, transport, web_rtc_transport}; +use mediasoup_sys::fbs::{common, rtp_packet, sctp_association, transport, web_rtc_transport}; use serde::de::{MapAccess, Visitor}; use serde::ser::SerializeStruct; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs deleted file mode 100644 index 3438014f03..0000000000 --- a/rust/src/fbs.rs +++ /dev/null @@ -1,80106 +0,0 @@ -//! Flatbuffers data structures compiled from `.fbs` files -pub use root::fbs::*; - -const _: () = ::planus::check_version_compatibility("planus-0.4.0"); - -/// The root namespace -/// -/// Generated from these locations: -/// * File `../worker/fbs/activeSpeakerObserver.fbs` -#[no_implicit_prelude] -mod root { - /// The namespace `FBS` - /// - /// Generated from these locations: - /// * File `../worker/fbs/activeSpeakerObserver.fbs` - #[allow(missing_docs)] - #[allow(clippy::all)] - pub mod fbs { - /// The namespace `FBS.ActiveSpeakerObserver` - /// - /// Generated from these locations: - /// * File `../worker/fbs/activeSpeakerObserver.fbs` - pub mod active_speaker_observer { - /// The table `ActiveSpeakerObserverOptions` in the namespace `FBS.ActiveSpeakerObserver` - /// - /// Generated from these locations: - /// * Table `ActiveSpeakerObserverOptions` in the file `../worker/fbs/activeSpeakerObserver.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ActiveSpeakerObserverOptions { - /// The field `interval` in the table `ActiveSpeakerObserverOptions` - pub interval: u16, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ActiveSpeakerObserverOptions { - fn default() -> Self { - Self { interval: 0 } - } - } - - impl ActiveSpeakerObserverOptions { - /// Creates a [ActiveSpeakerObserverOptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ActiveSpeakerObserverOptionsBuilder<()> { - ActiveSpeakerObserverOptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_interval: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_interval = field_interval.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_interval.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_interval) = - prepared_interval - { - object_writer.write::<_, _, 2>(&prepared_interval); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for ActiveSpeakerObserverOptions - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for ActiveSpeakerObserverOptions - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ActiveSpeakerObserverOptions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ActiveSpeakerObserverOptions::create(builder, self.interval) - } - } - - /// Builder for serializing an instance of the [ActiveSpeakerObserverOptions] type. - /// - /// Can be created using the [ActiveSpeakerObserverOptions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ActiveSpeakerObserverOptionsBuilder(State); - - impl ActiveSpeakerObserverOptionsBuilder<()> { - /// Setter for the [`interval` field](ActiveSpeakerObserverOptions#structfield.interval). - #[inline] - #[allow(clippy::type_complexity)] - pub fn interval(self, value: T0) -> ActiveSpeakerObserverOptionsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ActiveSpeakerObserverOptionsBuilder((value,)) - } - - /// Sets the [`interval` field](ActiveSpeakerObserverOptions#structfield.interval) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn interval_as_default( - self, - ) -> ActiveSpeakerObserverOptionsBuilder<(::planus::DefaultValue,)> - { - self.interval(::planus::DefaultValue) - } - } - - impl ActiveSpeakerObserverOptionsBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ActiveSpeakerObserverOptions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for ActiveSpeakerObserverOptionsBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for ActiveSpeakerObserverOptionsBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for ActiveSpeakerObserverOptionsBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ActiveSpeakerObserverOptions::create(builder, v0) - } - } - - /// Reference to a deserialized [ActiveSpeakerObserverOptions]. - #[derive(Copy, Clone)] - pub struct ActiveSpeakerObserverOptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ActiveSpeakerObserverOptionsRef<'a> { - /// Getter for the [`interval` field](ActiveSpeakerObserverOptions#structfield.interval). - #[inline] - pub fn interval(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ActiveSpeakerObserverOptions", "interval")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for ActiveSpeakerObserverOptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ActiveSpeakerObserverOptionsRef"); - f.field("interval", &self.interval()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for ActiveSpeakerObserverOptions - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ActiveSpeakerObserverOptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - interval: ::core::convert::TryInto::try_into(value.interval()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ActiveSpeakerObserverOptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ActiveSpeakerObserverOptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ActiveSpeakerObserverOptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for ActiveSpeakerObserverOptions - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ActiveSpeakerObserverOptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[ActiveSpeakerObserverOptionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DominantSpeakerNotification` in the namespace `FBS.ActiveSpeakerObserver` - /// - /// Generated from these locations: - /// * Table `DominantSpeakerNotification` in the file `../worker/fbs/activeSpeakerObserver.fbs:9` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DominantSpeakerNotification { - /// The field `producer_id` in the table `DominantSpeakerNotification` - pub producer_id: ::planus::alloc::string::String, - } - - impl DominantSpeakerNotification { - /// Creates a [DominantSpeakerNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DominantSpeakerNotificationBuilder<()> { - DominantSpeakerNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_producer_id = field_producer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for DominantSpeakerNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for DominantSpeakerNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DominantSpeakerNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DominantSpeakerNotification::create(builder, &self.producer_id) - } - } - - /// Builder for serializing an instance of the [DominantSpeakerNotification] type. - /// - /// Can be created using the [DominantSpeakerNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DominantSpeakerNotificationBuilder(State); - - impl DominantSpeakerNotificationBuilder<()> { - /// Setter for the [`producer_id` field](DominantSpeakerNotification#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T0) -> DominantSpeakerNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DominantSpeakerNotificationBuilder((value,)) - } - } - - impl DominantSpeakerNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DominantSpeakerNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for DominantSpeakerNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for DominantSpeakerNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for DominantSpeakerNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - DominantSpeakerNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [DominantSpeakerNotification]. - #[derive(Copy, Clone)] - pub struct DominantSpeakerNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DominantSpeakerNotificationRef<'a> { - /// Getter for the [`producer_id` field](DominantSpeakerNotification#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "DominantSpeakerNotification", "producer_id") - } - } - - impl<'a> ::core::fmt::Debug for DominantSpeakerNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DominantSpeakerNotificationRef"); - f.field("producer_id", &self.producer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for DominantSpeakerNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DominantSpeakerNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DominantSpeakerNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DominantSpeakerNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DominantSpeakerNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for DominantSpeakerNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DominantSpeakerNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[DominantSpeakerNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.AudioLevelObserver` - /// - /// Generated from these locations: - /// * File `../worker/fbs/audioLevelObserver.fbs` - pub mod audio_level_observer { - /// The table `AudioLevelObserverOptions` in the namespace `FBS.AudioLevelObserver` - /// - /// Generated from these locations: - /// * Table `AudioLevelObserverOptions` in the file `../worker/fbs/audioLevelObserver.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct AudioLevelObserverOptions { - /// The field `max_entries` in the table `AudioLevelObserverOptions` - pub max_entries: u16, - /// The field `threshold` in the table `AudioLevelObserverOptions` - pub threshold: i8, - /// The field `interval` in the table `AudioLevelObserverOptions` - pub interval: u16, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for AudioLevelObserverOptions { - fn default() -> Self { - Self { - max_entries: 0, - threshold: 0, - interval: 0, - } - } - } - - impl AudioLevelObserverOptions { - /// Creates a [AudioLevelObserverOptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> AudioLevelObserverOptionsBuilder<()> { - AudioLevelObserverOptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_max_entries: impl ::planus::WriteAsDefault, - field_threshold: impl ::planus::WriteAsDefault, - field_interval: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_max_entries = field_max_entries.prepare(builder, &0); - let prepared_threshold = field_threshold.prepare(builder, &0); - let prepared_interval = field_interval.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - if prepared_max_entries.is_some() { - table_writer.write_entry::(0); - } - if prepared_interval.is_some() { - table_writer.write_entry::(2); - } - if prepared_threshold.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_max_entries) = - prepared_max_entries - { - object_writer.write::<_, _, 2>(&prepared_max_entries); - } - if let ::core::option::Option::Some(prepared_interval) = - prepared_interval - { - object_writer.write::<_, _, 2>(&prepared_interval); - } - if let ::core::option::Option::Some(prepared_threshold) = - prepared_threshold - { - object_writer.write::<_, _, 1>(&prepared_threshold); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for AudioLevelObserverOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for AudioLevelObserverOptions - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for AudioLevelObserverOptions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - AudioLevelObserverOptions::create( - builder, - self.max_entries, - self.threshold, - self.interval, - ) - } - } - - /// Builder for serializing an instance of the [AudioLevelObserverOptions] type. - /// - /// Can be created using the [AudioLevelObserverOptions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct AudioLevelObserverOptionsBuilder(State); - - impl AudioLevelObserverOptionsBuilder<()> { - /// Setter for the [`max_entries` field](AudioLevelObserverOptions#structfield.max_entries). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_entries(self, value: T0) -> AudioLevelObserverOptionsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - AudioLevelObserverOptionsBuilder((value,)) - } - - /// Sets the [`max_entries` field](AudioLevelObserverOptions#structfield.max_entries) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_entries_as_default( - self, - ) -> AudioLevelObserverOptionsBuilder<(::planus::DefaultValue,)> { - self.max_entries(::planus::DefaultValue) - } - } - - impl AudioLevelObserverOptionsBuilder<(T0,)> { - /// Setter for the [`threshold` field](AudioLevelObserverOptions#structfield.threshold). - #[inline] - #[allow(clippy::type_complexity)] - pub fn threshold(self, value: T1) -> AudioLevelObserverOptionsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - AudioLevelObserverOptionsBuilder((v0, value)) - } - - /// Sets the [`threshold` field](AudioLevelObserverOptions#structfield.threshold) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn threshold_as_default( - self, - ) -> AudioLevelObserverOptionsBuilder<(T0, ::planus::DefaultValue)> - { - self.threshold(::planus::DefaultValue) - } - } - - impl AudioLevelObserverOptionsBuilder<(T0, T1)> { - /// Setter for the [`interval` field](AudioLevelObserverOptions#structfield.interval). - #[inline] - #[allow(clippy::type_complexity)] - pub fn interval( - self, - value: T2, - ) -> AudioLevelObserverOptionsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - AudioLevelObserverOptionsBuilder((v0, v1, value)) - } - - /// Sets the [`interval` field](AudioLevelObserverOptions#structfield.interval) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn interval_as_default( - self, - ) -> AudioLevelObserverOptionsBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.interval(::planus::DefaultValue) - } - } - - impl AudioLevelObserverOptionsBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [AudioLevelObserverOptions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for AudioLevelObserverOptionsBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for AudioLevelObserverOptionsBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for AudioLevelObserverOptionsBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - AudioLevelObserverOptions::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [AudioLevelObserverOptions]. - #[derive(Copy, Clone)] - pub struct AudioLevelObserverOptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> AudioLevelObserverOptionsRef<'a> { - /// Getter for the [`max_entries` field](AudioLevelObserverOptions#structfield.max_entries). - #[inline] - pub fn max_entries(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "AudioLevelObserverOptions", "max_entries")? - .unwrap_or(0), - ) - } - - /// Getter for the [`threshold` field](AudioLevelObserverOptions#structfield.threshold). - #[inline] - pub fn threshold(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "AudioLevelObserverOptions", "threshold")? - .unwrap_or(0), - ) - } - - /// Getter for the [`interval` field](AudioLevelObserverOptions#structfield.interval). - #[inline] - pub fn interval(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "AudioLevelObserverOptions", "interval")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for AudioLevelObserverOptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("AudioLevelObserverOptionsRef"); - f.field("max_entries", &self.max_entries()); - f.field("threshold", &self.threshold()); - f.field("interval", &self.interval()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for AudioLevelObserverOptions { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: AudioLevelObserverOptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - max_entries: ::core::convert::TryInto::try_into(value.max_entries()?)?, - threshold: ::core::convert::TryInto::try_into(value.threshold()?)?, - interval: ::core::convert::TryInto::try_into(value.interval()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for AudioLevelObserverOptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for AudioLevelObserverOptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[AudioLevelObserverOptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for AudioLevelObserverOptions - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for AudioLevelObserverOptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[AudioLevelObserverOptionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `Volume` in the namespace `FBS.AudioLevelObserver` - /// - /// Generated from these locations: - /// * Table `Volume` in the file `../worker/fbs/audioLevelObserver.fbs:11` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Volume { - /// The field `producer_id` in the table `Volume` - pub producer_id: ::planus::alloc::string::String, - /// The field `volume` in the table `Volume` - pub volume: i8, - } - - impl Volume { - /// Creates a [VolumeBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> VolumeBuilder<()> { - VolumeBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_volume: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_producer_id = field_producer_id.prepare(builder); - let prepared_volume = field_volume.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_volume.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_id); - if let ::core::option::Option::Some(prepared_volume) = prepared_volume { - object_writer.write::<_, _, 1>(&prepared_volume); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Volume { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Volume { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Volume { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Volume::create(builder, &self.producer_id, self.volume) - } - } - - /// Builder for serializing an instance of the [Volume] type. - /// - /// Can be created using the [Volume::builder] method. - #[derive(Debug)] - #[must_use] - pub struct VolumeBuilder(State); - - impl VolumeBuilder<()> { - /// Setter for the [`producer_id` field](Volume#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T0) -> VolumeBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - VolumeBuilder((value,)) - } - } - - impl VolumeBuilder<(T0,)> { - /// Setter for the [`volume` field](Volume#structfield.volume). - #[inline] - #[allow(clippy::type_complexity)] - pub fn volume(self, value: T1) -> VolumeBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - VolumeBuilder((v0, value)) - } - - /// Sets the [`volume` field](Volume#structfield.volume) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn volume_as_default(self) -> VolumeBuilder<(T0, ::planus::DefaultValue)> { - self.volume(::planus::DefaultValue) - } - } - - impl VolumeBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Volume]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> for VolumeBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> for VolumeBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for VolumeBuilder<(T0, T1)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - Volume::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [Volume]. - #[derive(Copy, Clone)] - pub struct VolumeRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> VolumeRef<'a> { - /// Getter for the [`producer_id` field](Volume#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Volume", "producer_id") - } - - /// Getter for the [`volume` field](Volume#structfield.volume). - #[inline] - pub fn volume(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Volume", "volume")?.unwrap_or(0)) - } - } - - impl<'a> ::core::fmt::Debug for VolumeRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("VolumeRef"); - f.field("producer_id", &self.producer_id()); - f.field("volume", &self.volume()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Volume { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: VolumeRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - volume: ::core::convert::TryInto::try_into(value.volume()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for VolumeRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for VolumeRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[VolumeRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Volume { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for VolumeRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[VolumeRef]", "read_as_root", 0) - }) - } - } - - /// The table `VolumesNotification` in the namespace `FBS.AudioLevelObserver` - /// - /// Generated from these locations: - /// * Table `VolumesNotification` in the file `../worker/fbs/audioLevelObserver.fbs:16` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct VolumesNotification { - /// The field `volumes` in the table `VolumesNotification` - pub volumes: ::planus::alloc::vec::Vec, - } - - impl VolumesNotification { - /// Creates a [VolumesNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> VolumesNotificationBuilder<()> { - VolumesNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_volumes: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_volumes = field_volumes.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_volumes); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for VolumesNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for VolumesNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for VolumesNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - VolumesNotification::create(builder, &self.volumes) - } - } - - /// Builder for serializing an instance of the [VolumesNotification] type. - /// - /// Can be created using the [VolumesNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct VolumesNotificationBuilder(State); - - impl VolumesNotificationBuilder<()> { - /// Setter for the [`volumes` field](VolumesNotification#structfield.volumes). - #[inline] - #[allow(clippy::type_complexity)] - pub fn volumes(self, value: T0) -> VolumesNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - VolumesNotificationBuilder((value,)) - } - } - - impl VolumesNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [VolumesNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl]>>> - ::planus::WriteAs<::planus::Offset> - for VolumesNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl]>>> - ::planus::WriteAsOptional<::planus::Offset> - for VolumesNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl]>>> - ::planus::WriteAsOffset for VolumesNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - VolumesNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [VolumesNotification]. - #[derive(Copy, Clone)] - pub struct VolumesNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> VolumesNotificationRef<'a> { - /// Getter for the [`volumes` field](VolumesNotification#structfield.volumes). - #[inline] - pub fn volumes( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(0, "VolumesNotification", "volumes") - } - } - - impl<'a> ::core::fmt::Debug for VolumesNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("VolumesNotificationRef"); - f.field("volumes", &self.volumes()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for VolumesNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: VolumesNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - volumes: value.volumes()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for VolumesNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for VolumesNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[VolumesNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for VolumesNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for VolumesNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[VolumesNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.Common` - /// - /// Generated from these locations: - /// * File `../worker/fbs/common.fbs` - pub mod common { - /// The table `StringString` in the namespace `FBS.Common` - /// - /// Generated from these locations: - /// * Table `StringString` in the file `../worker/fbs/common.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct StringString { - /// The field `key` in the table `StringString` - pub key: ::planus::alloc::string::String, - /// The field `value` in the table `StringString` - pub value: ::planus::alloc::string::String, - } - - impl StringString { - /// Creates a [StringStringBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StringStringBuilder<()> { - StringStringBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_key: impl ::planus::WriteAs<::planus::Offset>, - field_value: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_key = field_key.prepare(builder); - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_key); - object_writer.write::<_, _, 4>(&prepared_value); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for StringString { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for StringString { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for StringString { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - StringString::create(builder, &self.key, &self.value) - } - } - - /// Builder for serializing an instance of the [StringString] type. - /// - /// Can be created using the [StringString::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StringStringBuilder(State); - - impl StringStringBuilder<()> { - /// Setter for the [`key` field](StringString#structfield.key). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key(self, value: T0) -> StringStringBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - StringStringBuilder((value,)) - } - } - - impl StringStringBuilder<(T0,)> { - /// Setter for the [`value` field](StringString#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> StringStringBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - StringStringBuilder((v0, value)) - } - } - - impl StringStringBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [StringString]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for StringStringBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for StringStringBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for StringStringBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - StringString::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [StringString]. - #[derive(Copy, Clone)] - pub struct StringStringRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> StringStringRef<'a> { - /// Getter for the [`key` field](StringString#structfield.key). - #[inline] - pub fn key(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "StringString", "key") - } - - /// Getter for the [`value` field](StringString#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "StringString", "value") - } - } - - impl<'a> ::core::fmt::Debug for StringStringRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("StringStringRef"); - f.field("key", &self.key()); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for StringString { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: StringStringRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - key: ::core::convert::TryInto::try_into(value.key()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for StringStringRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for StringStringRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[StringStringRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for StringString { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for StringStringRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[StringStringRef]", "read_as_root", 0) - }) - } - } - - /// The table `StringUint8` in the namespace `FBS.Common` - /// - /// Generated from these locations: - /// * Table `StringUint8` in the file `../worker/fbs/common.fbs:8` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct StringUint8 { - /// The field `key` in the table `StringUint8` - pub key: ::planus::alloc::string::String, - /// The field `value` in the table `StringUint8` - pub value: u8, - } - - impl StringUint8 { - /// Creates a [StringUint8Builder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StringUint8Builder<()> { - StringUint8Builder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_key: impl ::planus::WriteAs<::planus::Offset>, - field_value: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_key = field_key.prepare(builder); - let prepared_value = field_value.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_value.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_key); - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 1>(&prepared_value); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for StringUint8 { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for StringUint8 { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for StringUint8 { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - StringUint8::create(builder, &self.key, self.value) - } - } - - /// Builder for serializing an instance of the [StringUint8] type. - /// - /// Can be created using the [StringUint8::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StringUint8Builder(State); - - impl StringUint8Builder<()> { - /// Setter for the [`key` field](StringUint8#structfield.key). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key(self, value: T0) -> StringUint8Builder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - StringUint8Builder((value,)) - } - } - - impl StringUint8Builder<(T0,)> { - /// Setter for the [`value` field](StringUint8#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> StringUint8Builder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - StringUint8Builder((v0, value)) - } - - /// Sets the [`value` field](StringUint8#structfield.value) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_default(self) -> StringUint8Builder<(T0, ::planus::DefaultValue)> { - self.value(::planus::DefaultValue) - } - } - - impl StringUint8Builder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [StringUint8]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for StringUint8Builder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for StringUint8Builder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for StringUint8Builder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - StringUint8::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [StringUint8]. - #[derive(Copy, Clone)] - pub struct StringUint8Ref<'a>(::planus::table_reader::Table<'a>); - - impl<'a> StringUint8Ref<'a> { - /// Getter for the [`key` field](StringUint8#structfield.key). - #[inline] - pub fn key(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "StringUint8", "key") - } - - /// Getter for the [`value` field](StringUint8#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "StringUint8", "value")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for StringUint8Ref<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("StringUint8Ref"); - f.field("key", &self.key()); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for StringUint8 { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: StringUint8Ref<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - key: ::core::convert::TryInto::try_into(value.key()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for StringUint8Ref<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for StringUint8Ref<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[StringUint8Ref]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for StringUint8 { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for StringUint8Ref<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[StringUint8Ref]", "read_as_root", 0) - }) - } - } - - /// The table `Uint16String` in the namespace `FBS.Common` - /// - /// Generated from these locations: - /// * Table `Uint16String` in the file `../worker/fbs/common.fbs:13` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Uint16String { - /// The field `key` in the table `Uint16String` - pub key: u16, - /// The field `value` in the table `Uint16String` - pub value: ::planus::alloc::string::String, - } - - impl Uint16String { - /// Creates a [Uint16StringBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> Uint16StringBuilder<()> { - Uint16StringBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_key: impl ::planus::WriteAsDefault, - field_value: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_key = field_key.prepare(builder, &0); - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_key.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); - if let ::core::option::Option::Some(prepared_key) = prepared_key { - object_writer.write::<_, _, 2>(&prepared_key); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Uint16String { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Uint16String { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Uint16String { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - Uint16String::create(builder, self.key, &self.value) - } - } - - /// Builder for serializing an instance of the [Uint16String] type. - /// - /// Can be created using the [Uint16String::builder] method. - #[derive(Debug)] - #[must_use] - pub struct Uint16StringBuilder(State); - - impl Uint16StringBuilder<()> { - /// Setter for the [`key` field](Uint16String#structfield.key). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key(self, value: T0) -> Uint16StringBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - Uint16StringBuilder((value,)) - } - - /// Sets the [`key` field](Uint16String#structfield.key) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn key_as_default(self) -> Uint16StringBuilder<(::planus::DefaultValue,)> { - self.key(::planus::DefaultValue) - } - } - - impl Uint16StringBuilder<(T0,)> { - /// Setter for the [`value` field](Uint16String#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> Uint16StringBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - Uint16StringBuilder((v0, value)) - } - } - - impl Uint16StringBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Uint16String]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for Uint16StringBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for Uint16StringBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for Uint16StringBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - Uint16String::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [Uint16String]. - #[derive(Copy, Clone)] - pub struct Uint16StringRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> Uint16StringRef<'a> { - /// Getter for the [`key` field](Uint16String#structfield.key). - #[inline] - pub fn key(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "Uint16String", "key")?.unwrap_or(0), - ) - } - - /// Getter for the [`value` field](Uint16String#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "Uint16String", "value") - } - } - - impl<'a> ::core::fmt::Debug for Uint16StringRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("Uint16StringRef"); - f.field("key", &self.key()); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Uint16String { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: Uint16StringRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - key: ::core::convert::TryInto::try_into(value.key()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for Uint16StringRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for Uint16StringRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[Uint16StringRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Uint16String { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for Uint16StringRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[Uint16StringRef]", "read_as_root", 0) - }) - } - } - - /// The table `Uint32String` in the namespace `FBS.Common` - /// - /// Generated from these locations: - /// * Table `Uint32String` in the file `../worker/fbs/common.fbs:18` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Uint32String { - /// The field `key` in the table `Uint32String` - pub key: u32, - /// The field `value` in the table `Uint32String` - pub value: ::planus::alloc::string::String, - } - - impl Uint32String { - /// Creates a [Uint32StringBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> Uint32StringBuilder<()> { - Uint32StringBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_key: impl ::planus::WriteAsDefault, - field_value: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_key = field_key.prepare(builder, &0); - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_key.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_key) = prepared_key { - object_writer.write::<_, _, 4>(&prepared_key); - } - object_writer.write::<_, _, 4>(&prepared_value); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Uint32String { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Uint32String { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Uint32String { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - Uint32String::create(builder, self.key, &self.value) - } - } - - /// Builder for serializing an instance of the [Uint32String] type. - /// - /// Can be created using the [Uint32String::builder] method. - #[derive(Debug)] - #[must_use] - pub struct Uint32StringBuilder(State); - - impl Uint32StringBuilder<()> { - /// Setter for the [`key` field](Uint32String#structfield.key). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key(self, value: T0) -> Uint32StringBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - Uint32StringBuilder((value,)) - } - - /// Sets the [`key` field](Uint32String#structfield.key) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn key_as_default(self) -> Uint32StringBuilder<(::planus::DefaultValue,)> { - self.key(::planus::DefaultValue) - } - } - - impl Uint32StringBuilder<(T0,)> { - /// Setter for the [`value` field](Uint32String#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> Uint32StringBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - Uint32StringBuilder((v0, value)) - } - } - - impl Uint32StringBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Uint32String]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for Uint32StringBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for Uint32StringBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for Uint32StringBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - Uint32String::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [Uint32String]. - #[derive(Copy, Clone)] - pub struct Uint32StringRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> Uint32StringRef<'a> { - /// Getter for the [`key` field](Uint32String#structfield.key). - #[inline] - pub fn key(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "Uint32String", "key")?.unwrap_or(0), - ) - } - - /// Getter for the [`value` field](Uint32String#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "Uint32String", "value") - } - } - - impl<'a> ::core::fmt::Debug for Uint32StringRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("Uint32StringRef"); - f.field("key", &self.key()); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Uint32String { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: Uint32StringRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - key: ::core::convert::TryInto::try_into(value.key()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for Uint32StringRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for Uint32StringRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[Uint32StringRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Uint32String { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for Uint32StringRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[Uint32StringRef]", "read_as_root", 0) - }) - } - } - - /// The table `StringStringArray` in the namespace `FBS.Common` - /// - /// Generated from these locations: - /// * Table `StringStringArray` in the file `../worker/fbs/common.fbs:23` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct StringStringArray { - /// The field `key` in the table `StringStringArray` - pub key: ::planus::alloc::string::String, - /// The field `values` in the table `StringStringArray` - pub values: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - } - - impl StringStringArray { - /// Creates a [StringStringArrayBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StringStringArrayBuilder<()> { - StringStringArrayBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_key: impl ::planus::WriteAs<::planus::Offset>, - field_values: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - ) -> ::planus::Offset { - let prepared_key = field_key.prepare(builder); - let prepared_values = field_values.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_key); - object_writer.write::<_, _, 4>(&prepared_values); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for StringStringArray { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for StringStringArray { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for StringStringArray { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - StringStringArray::create(builder, &self.key, &self.values) - } - } - - /// Builder for serializing an instance of the [StringStringArray] type. - /// - /// Can be created using the [StringStringArray::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StringStringArrayBuilder(State); - - impl StringStringArrayBuilder<()> { - /// Setter for the [`key` field](StringStringArray#structfield.key). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key(self, value: T0) -> StringStringArrayBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - StringStringArrayBuilder((value,)) - } - } - - impl StringStringArrayBuilder<(T0,)> { - /// Setter for the [`values` field](StringStringArray#structfield.values). - #[inline] - #[allow(clippy::type_complexity)] - pub fn values(self, value: T1) -> StringStringArrayBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0,) = self.0; - StringStringArrayBuilder((v0, value)) - } - } - - impl StringStringArrayBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [StringStringArray]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> - for StringStringArrayBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for StringStringArrayBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset - for StringStringArrayBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - StringStringArray::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [StringStringArray]. - #[derive(Copy, Clone)] - pub struct StringStringArrayRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> StringStringArrayRef<'a> { - /// Getter for the [`key` field](StringStringArray#structfield.key). - #[inline] - pub fn key(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "StringStringArray", "key") - } - - /// Getter for the [`values` field](StringStringArray#structfield.values). - #[inline] - pub fn values( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(1, "StringStringArray", "values") - } - } - - impl<'a> ::core::fmt::Debug for StringStringArrayRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("StringStringArrayRef"); - f.field("key", &self.key()); - f.field("values", &self.values()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for StringStringArray { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: StringStringArrayRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - key: ::core::convert::TryInto::try_into(value.key()?)?, - values: value.values()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for StringStringArrayRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for StringStringArrayRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[StringStringArrayRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for StringStringArray { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for StringStringArrayRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[StringStringArrayRef]", "read_as_root", 0) - }) - } - } - - /// The enum `TraceDirection` in the namespace `FBS.Common` - /// - /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/common.fbs:29` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceDirection { - /// The variant `DIRECTION_IN` in the enum `TraceDirection` - DirectionIn = 0, - - /// The variant `DIRECTION_OUT` in the enum `TraceDirection` - DirectionOut = 1, - } - - impl TraceDirection { - /// Array containing all valid variants of TraceDirection - pub const ENUM_VALUES: [Self; 2] = [Self::DirectionIn, Self::DirectionOut]; - } - - impl ::core::convert::TryFrom for TraceDirection { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(TraceDirection::DirectionIn), - 1 => ::core::result::Result::Ok(TraceDirection::DirectionOut), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceDirection) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceDirection { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceDirection { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceDirection { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceDirection { - *self - } - } - - impl ::planus::WriteAsDefault for TraceDirection { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceDirection, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceDirection { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for TraceDirection { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for TraceDirection { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "TraceDirection", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for TraceDirection { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - } - /// The namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/consumer.fbs` - pub mod consumer { - /// The table `ConsumerLayers` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `ConsumerLayers` in the file `../worker/fbs/consumer.fbs:8` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConsumerLayers { - /// The field `spatial_layer` in the table `ConsumerLayers` - pub spatial_layer: u8, - /// The field `temporal_layer` in the table `ConsumerLayers` - pub temporal_layer: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ConsumerLayers { - fn default() -> Self { - Self { - spatial_layer: 0, - temporal_layer: ::core::default::Default::default(), - } - } - } - - impl ConsumerLayers { - /// Creates a [ConsumerLayersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConsumerLayersBuilder<()> { - ConsumerLayersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_spatial_layer: impl ::planus::WriteAsDefault, - field_temporal_layer: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_spatial_layer = field_spatial_layer.prepare(builder, &0); - let prepared_temporal_layer = field_temporal_layer.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_spatial_layer.is_some() { - table_writer.write_entry::(0); - } - if prepared_temporal_layer.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_spatial_layer) = - prepared_spatial_layer - { - object_writer.write::<_, _, 1>(&prepared_spatial_layer); - } - if let ::core::option::Option::Some(prepared_temporal_layer) = - prepared_temporal_layer - { - object_writer.write::<_, _, 1>(&prepared_temporal_layer); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConsumerLayers { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConsumerLayers { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConsumerLayers { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConsumerLayers::create(builder, self.spatial_layer, self.temporal_layer) - } - } - - /// Builder for serializing an instance of the [ConsumerLayers] type. - /// - /// Can be created using the [ConsumerLayers::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConsumerLayersBuilder(State); - - impl ConsumerLayersBuilder<()> { - /// Setter for the [`spatial_layer` field](ConsumerLayers#structfield.spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn spatial_layer(self, value: T0) -> ConsumerLayersBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ConsumerLayersBuilder((value,)) - } - - /// Sets the [`spatial_layer` field](ConsumerLayers#structfield.spatial_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn spatial_layer_as_default( - self, - ) -> ConsumerLayersBuilder<(::planus::DefaultValue,)> { - self.spatial_layer(::planus::DefaultValue) - } - } - - impl ConsumerLayersBuilder<(T0,)> { - /// Setter for the [`temporal_layer` field](ConsumerLayers#structfield.temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn temporal_layer(self, value: T1) -> ConsumerLayersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - ConsumerLayersBuilder((v0, value)) - } - - /// Sets the [`temporal_layer` field](ConsumerLayers#structfield.temporal_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn temporal_layer_as_null(self) -> ConsumerLayersBuilder<(T0, ())> { - self.temporal_layer(()) - } - } - - impl ConsumerLayersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConsumerLayers]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl, T1: ::planus::WriteAsOptional> - ::planus::WriteAs<::planus::Offset> - for ConsumerLayersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl, T1: ::planus::WriteAsOptional> - ::planus::WriteAsOptional<::planus::Offset> - for ConsumerLayersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl, T1: ::planus::WriteAsOptional> - ::planus::WriteAsOffset for ConsumerLayersBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - ConsumerLayers::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [ConsumerLayers]. - #[derive(Copy, Clone)] - pub struct ConsumerLayersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConsumerLayersRef<'a> { - /// Getter for the [`spatial_layer` field](ConsumerLayers#structfield.spatial_layer). - #[inline] - pub fn spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ConsumerLayers", "spatial_layer")? - .unwrap_or(0), - ) - } - - /// Getter for the [`temporal_layer` field](ConsumerLayers#structfield.temporal_layer). - #[inline] - pub fn temporal_layer(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "ConsumerLayers", "temporal_layer") - } - } - - impl<'a> ::core::fmt::Debug for ConsumerLayersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConsumerLayersRef"); - f.field("spatial_layer", &self.spatial_layer()); - if let ::core::option::Option::Some(field_temporal_layer) = - self.temporal_layer().transpose() - { - f.field("temporal_layer", &field_temporal_layer); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConsumerLayers { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConsumerLayersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - spatial_layer: ::core::convert::TryInto::try_into(value.spatial_layer()?)?, - temporal_layer: if let ::core::option::Option::Some(temporal_layer) = - value.temporal_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - temporal_layer, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConsumerLayersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConsumerLayersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConsumerLayersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConsumerLayers { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConsumerLayersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConsumerLayersRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConsumerScore` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `ConsumerScore` in the file `../worker/fbs/consumer.fbs:13` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConsumerScore { - /// The field `score` in the table `ConsumerScore` - pub score: u8, - /// The field `producer_score` in the table `ConsumerScore` - pub producer_score: u8, - /// The field `producer_scores` in the table `ConsumerScore` - pub producer_scores: ::planus::alloc::vec::Vec, - } - - impl ConsumerScore { - /// Creates a [ConsumerScoreBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConsumerScoreBuilder<()> { - ConsumerScoreBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_score: impl ::planus::WriteAsDefault, - field_producer_score: impl ::planus::WriteAsDefault, - field_producer_scores: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_score = field_score.prepare(builder, &0); - let prepared_producer_score = field_producer_score.prepare(builder, &0); - let prepared_producer_scores = field_producer_scores.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u8]>>(2); - if prepared_score.is_some() { - table_writer.write_entry::(0); - } - if prepared_producer_score.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_scores); - if let ::core::option::Option::Some(prepared_score) = prepared_score { - object_writer.write::<_, _, 1>(&prepared_score); - } - if let ::core::option::Option::Some(prepared_producer_score) = - prepared_producer_score - { - object_writer.write::<_, _, 1>(&prepared_producer_score); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConsumerScore { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConsumerScore { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConsumerScore { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConsumerScore::create( - builder, - self.score, - self.producer_score, - &self.producer_scores, - ) - } - } - - /// Builder for serializing an instance of the [ConsumerScore] type. - /// - /// Can be created using the [ConsumerScore::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConsumerScoreBuilder(State); - - impl ConsumerScoreBuilder<()> { - /// Setter for the [`score` field](ConsumerScore#structfield.score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn score(self, value: T0) -> ConsumerScoreBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ConsumerScoreBuilder((value,)) - } - - /// Sets the [`score` field](ConsumerScore#structfield.score) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn score_as_default(self) -> ConsumerScoreBuilder<(::planus::DefaultValue,)> { - self.score(::planus::DefaultValue) - } - } - - impl ConsumerScoreBuilder<(T0,)> { - /// Setter for the [`producer_score` field](ConsumerScore#structfield.producer_score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_score(self, value: T1) -> ConsumerScoreBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ConsumerScoreBuilder((v0, value)) - } - - /// Sets the [`producer_score` field](ConsumerScore#structfield.producer_score) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_score_as_default( - self, - ) -> ConsumerScoreBuilder<(T0, ::planus::DefaultValue)> { - self.producer_score(::planus::DefaultValue) - } - } - - impl ConsumerScoreBuilder<(T0, T1)> { - /// Setter for the [`producer_scores` field](ConsumerScore#structfield.producer_scores). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_scores(self, value: T2) -> ConsumerScoreBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - let (v0, v1) = self.0; - ConsumerScoreBuilder((v0, v1, value)) - } - } - - impl ConsumerScoreBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConsumerScore]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAs<::planus::Offset> - for ConsumerScoreBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for ConsumerScoreBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAsOffset for ConsumerScoreBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - ConsumerScore::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [ConsumerScore]. - #[derive(Copy, Clone)] - pub struct ConsumerScoreRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConsumerScoreRef<'a> { - /// Getter for the [`score` field](ConsumerScore#structfield.score). - #[inline] - pub fn score(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "ConsumerScore", "score")?.unwrap_or(0), - ) - } - - /// Getter for the [`producer_score` field](ConsumerScore#structfield.producer_score). - #[inline] - pub fn producer_score(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "ConsumerScore", "producer_score")? - .unwrap_or(0), - ) - } - - /// Getter for the [`producer_scores` field](ConsumerScore#structfield.producer_scores). - #[inline] - pub fn producer_scores(&self) -> ::planus::Result<&'a [u8]> { - self.0 - .access_required(2, "ConsumerScore", "producer_scores") - } - } - - impl<'a> ::core::fmt::Debug for ConsumerScoreRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConsumerScoreRef"); - f.field("score", &self.score()); - f.field("producer_score", &self.producer_score()); - f.field("producer_scores", &self.producer_scores()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConsumerScore { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConsumerScoreRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - score: ::core::convert::TryInto::try_into(value.score()?)?, - producer_score: ::core::convert::TryInto::try_into( - value.producer_score()?, - )?, - producer_scores: value.producer_scores()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConsumerScoreRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConsumerScoreRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConsumerScoreRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConsumerScore { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConsumerScoreRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConsumerScoreRef]", "read_as_root", 0) - }) - } - } - - /// The table `SetPreferredLayersRequest` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `SetPreferredLayersRequest` in the file `../worker/fbs/consumer.fbs:19` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetPreferredLayersRequest { - /// The field `preferred_layers` in the table `SetPreferredLayersRequest` - pub preferred_layers: ::planus::alloc::boxed::Box, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetPreferredLayersRequest { - fn default() -> Self { - Self { - preferred_layers: ::core::default::Default::default(), - } - } - } - - impl SetPreferredLayersRequest { - /// Creates a [SetPreferredLayersRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetPreferredLayersRequestBuilder<()> { - SetPreferredLayersRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_preferred_layers: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_preferred_layers = field_preferred_layers.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_preferred_layers); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SetPreferredLayersRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetPreferredLayersRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetPreferredLayersRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetPreferredLayersRequest::create(builder, &self.preferred_layers) - } - } - - /// Builder for serializing an instance of the [SetPreferredLayersRequest] type. - /// - /// Can be created using the [SetPreferredLayersRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetPreferredLayersRequestBuilder(State); - - impl SetPreferredLayersRequestBuilder<()> { - /// Setter for the [`preferred_layers` field](SetPreferredLayersRequest#structfield.preferred_layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers( - self, - value: T0, - ) -> SetPreferredLayersRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - SetPreferredLayersRequestBuilder((value,)) - } - } - - impl SetPreferredLayersRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetPreferredLayersRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for SetPreferredLayersRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SetPreferredLayersRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for SetPreferredLayersRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetPreferredLayersRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetPreferredLayersRequest]. - #[derive(Copy, Clone)] - pub struct SetPreferredLayersRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetPreferredLayersRequestRef<'a> { - /// Getter for the [`preferred_layers` field](SetPreferredLayersRequest#structfield.preferred_layers). - #[inline] - pub fn preferred_layers(&self) -> ::planus::Result> { - self.0 - .access_required(0, "SetPreferredLayersRequest", "preferred_layers") - } - } - - impl<'a> ::core::fmt::Debug for SetPreferredLayersRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetPreferredLayersRequestRef"); - f.field("preferred_layers", &self.preferred_layers()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SetPreferredLayersRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetPreferredLayersRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - preferred_layers: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.preferred_layers()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetPreferredLayersRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetPreferredLayersRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetPreferredLayersRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SetPreferredLayersRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetPreferredLayersRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetPreferredLayersRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SetPreferredLayersResponse` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `SetPreferredLayersResponse` in the file `../worker/fbs/consumer.fbs:23` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetPreferredLayersResponse { - /// The field `preferred_layers` in the table `SetPreferredLayersResponse` - pub preferred_layers: - ::core::option::Option<::planus::alloc::boxed::Box>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetPreferredLayersResponse { - fn default() -> Self { - Self { - preferred_layers: ::core::default::Default::default(), - } - } - } - - impl SetPreferredLayersResponse { - /// Creates a [SetPreferredLayersResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetPreferredLayersResponseBuilder<()> { - SetPreferredLayersResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_preferred_layers: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_preferred_layers = field_preferred_layers.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_preferred_layers.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_preferred_layers) = - prepared_preferred_layers - { - object_writer.write::<_, _, 4>(&prepared_preferred_layers); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for SetPreferredLayersResponse - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetPreferredLayersResponse - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetPreferredLayersResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetPreferredLayersResponse::create(builder, &self.preferred_layers) - } - } - - /// Builder for serializing an instance of the [SetPreferredLayersResponse] type. - /// - /// Can be created using the [SetPreferredLayersResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetPreferredLayersResponseBuilder(State); - - impl SetPreferredLayersResponseBuilder<()> { - /// Setter for the [`preferred_layers` field](SetPreferredLayersResponse#structfield.preferred_layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers( - self, - value: T0, - ) -> SetPreferredLayersResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset>, - { - SetPreferredLayersResponseBuilder((value,)) - } - - /// Sets the [`preferred_layers` field](SetPreferredLayersResponse#structfield.preferred_layers) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers_as_null(self) -> SetPreferredLayersResponseBuilder<((),)> { - self.preferred_layers(()) - } - } - - impl SetPreferredLayersResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetPreferredLayersResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for SetPreferredLayersResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SetPreferredLayersResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for SetPreferredLayersResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetPreferredLayersResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [SetPreferredLayersResponse]. - #[derive(Copy, Clone)] - pub struct SetPreferredLayersResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetPreferredLayersResponseRef<'a> { - /// Getter for the [`preferred_layers` field](SetPreferredLayersResponse#structfield.preferred_layers). - #[inline] - pub fn preferred_layers( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0 - .access(0, "SetPreferredLayersResponse", "preferred_layers") - } - } - - impl<'a> ::core::fmt::Debug for SetPreferredLayersResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetPreferredLayersResponseRef"); - if let ::core::option::Option::Some(field_preferred_layers) = - self.preferred_layers().transpose() - { - f.field("preferred_layers", &field_preferred_layers); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for SetPreferredLayersResponse - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetPreferredLayersResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - preferred_layers: if let ::core::option::Option::Some(preferred_layers) = - value.preferred_layers()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(preferred_layers)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetPreferredLayersResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetPreferredLayersResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetPreferredLayersResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SetPreferredLayersResponse - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetPreferredLayersResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetPreferredLayersResponseRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SetPriorityRequest` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `SetPriorityRequest` in the file `../worker/fbs/consumer.fbs:27` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetPriorityRequest { - /// The field `priority` in the table `SetPriorityRequest` - pub priority: u8, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetPriorityRequest { - fn default() -> Self { - Self { priority: 0 } - } - } - - impl SetPriorityRequest { - /// Creates a [SetPriorityRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetPriorityRequestBuilder<()> { - SetPriorityRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_priority: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_priority = field_priority.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_priority.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_priority) = - prepared_priority - { - object_writer.write::<_, _, 1>(&prepared_priority); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SetPriorityRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SetPriorityRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetPriorityRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetPriorityRequest::create(builder, self.priority) - } - } - - /// Builder for serializing an instance of the [SetPriorityRequest] type. - /// - /// Can be created using the [SetPriorityRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetPriorityRequestBuilder(State); - - impl SetPriorityRequestBuilder<()> { - /// Setter for the [`priority` field](SetPriorityRequest#structfield.priority). - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority(self, value: T0) -> SetPriorityRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SetPriorityRequestBuilder((value,)) - } - - /// Sets the [`priority` field](SetPriorityRequest#structfield.priority) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority_as_default( - self, - ) -> SetPriorityRequestBuilder<(::planus::DefaultValue,)> { - self.priority(::planus::DefaultValue) - } - } - - impl SetPriorityRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetPriorityRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for SetPriorityRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for SetPriorityRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for SetPriorityRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetPriorityRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetPriorityRequest]. - #[derive(Copy, Clone)] - pub struct SetPriorityRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetPriorityRequestRef<'a> { - /// Getter for the [`priority` field](SetPriorityRequest#structfield.priority). - #[inline] - pub fn priority(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SetPriorityRequest", "priority")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SetPriorityRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetPriorityRequestRef"); - f.field("priority", &self.priority()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SetPriorityRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetPriorityRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - priority: ::core::convert::TryInto::try_into(value.priority()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetPriorityRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetPriorityRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetPriorityRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SetPriorityRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetPriorityRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SetPriorityRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `SetPriorityResponse` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `SetPriorityResponse` in the file `../worker/fbs/consumer.fbs:31` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetPriorityResponse { - /// The field `priority` in the table `SetPriorityResponse` - pub priority: u8, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetPriorityResponse { - fn default() -> Self { - Self { priority: 0 } - } - } - - impl SetPriorityResponse { - /// Creates a [SetPriorityResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetPriorityResponseBuilder<()> { - SetPriorityResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_priority: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_priority = field_priority.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_priority.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_priority) = - prepared_priority - { - object_writer.write::<_, _, 1>(&prepared_priority); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SetPriorityResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SetPriorityResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetPriorityResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetPriorityResponse::create(builder, self.priority) - } - } - - /// Builder for serializing an instance of the [SetPriorityResponse] type. - /// - /// Can be created using the [SetPriorityResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetPriorityResponseBuilder(State); - - impl SetPriorityResponseBuilder<()> { - /// Setter for the [`priority` field](SetPriorityResponse#structfield.priority). - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority(self, value: T0) -> SetPriorityResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SetPriorityResponseBuilder((value,)) - } - - /// Sets the [`priority` field](SetPriorityResponse#structfield.priority) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority_as_default( - self, - ) -> SetPriorityResponseBuilder<(::planus::DefaultValue,)> { - self.priority(::planus::DefaultValue) - } - } - - impl SetPriorityResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetPriorityResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for SetPriorityResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for SetPriorityResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for SetPriorityResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetPriorityResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [SetPriorityResponse]. - #[derive(Copy, Clone)] - pub struct SetPriorityResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetPriorityResponseRef<'a> { - /// Getter for the [`priority` field](SetPriorityResponse#structfield.priority). - #[inline] - pub fn priority(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SetPriorityResponse", "priority")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SetPriorityResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetPriorityResponseRef"); - f.field("priority", &self.priority()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SetPriorityResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetPriorityResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - priority: ::core::convert::TryInto::try_into(value.priority()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetPriorityResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetPriorityResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetPriorityResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SetPriorityResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetPriorityResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetPriorityResponseRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The enum `TraceEventType` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/consumer.fbs:35` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceEventType { - /// The variant `KEYFRAME` in the enum `TraceEventType` - Keyframe = 0, - - /// The variant `FIR` in the enum `TraceEventType` - Fir = 1, - - /// The variant `NACK` in the enum `TraceEventType` - Nack = 2, - - /// The variant `PLI` in the enum `TraceEventType` - Pli = 3, - - /// The variant `RTP` in the enum `TraceEventType` - Rtp = 4, - } - - impl TraceEventType { - /// Array containing all valid variants of TraceEventType - pub const ENUM_VALUES: [Self; 5] = - [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; - } - - impl ::core::convert::TryFrom for TraceEventType { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(TraceEventType::Keyframe), - 1 => ::core::result::Result::Ok(TraceEventType::Fir), - 2 => ::core::result::Result::Ok(TraceEventType::Nack), - 3 => ::core::result::Result::Ok(TraceEventType::Pli), - 4 => ::core::result::Result::Ok(TraceEventType::Rtp), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceEventType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceEventType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceEventType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceEventType { - *self - } - } - - impl ::planus::WriteAsDefault for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceEventType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for TraceEventType { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for TraceEventType { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "TraceEventType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for TraceEventType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `EnableTraceEventRequest` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/consumer.fbs:43` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct EnableTraceEventRequest { - /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec, - } - - impl EnableTraceEventRequest { - /// Creates a [EnableTraceEventRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> EnableTraceEventRequestBuilder<()> { - EnableTraceEventRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - ) -> ::planus::Offset { - let prepared_events = field_events.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_events); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for EnableTraceEventRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - EnableTraceEventRequest::create(builder, &self.events) - } - } - - /// Builder for serializing an instance of the [EnableTraceEventRequest] type. - /// - /// Can be created using the [EnableTraceEventRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct EnableTraceEventRequestBuilder(State); - - impl EnableTraceEventRequestBuilder<()> { - /// Setter for the [`events` field](EnableTraceEventRequest#structfield.events). - #[inline] - #[allow(clippy::type_complexity)] - pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - { - EnableTraceEventRequestBuilder((value,)) - } - } - - impl EnableTraceEventRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [EnableTraceEventRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for EnableTraceEventRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - EnableTraceEventRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [EnableTraceEventRequest]. - #[derive(Copy, Clone)] - pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> EnableTraceEventRequestRef<'a> { - /// Getter for the [`events` field](EnableTraceEventRequest#structfield.events). - #[inline] - pub fn events( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::core::result::Result< - self::TraceEventType, - ::planus::errors::UnknownEnumTag, - >, - >, - > { - self.0 - .access_required(0, "EnableTraceEventRequest", "events") - } - } - - impl<'a> ::core::fmt::Debug for EnableTraceEventRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("EnableTraceEventRequestRef"); - f.field("events", &self.events()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for EnableTraceEventRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: EnableTraceEventRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - events: value.events()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for EnableTraceEventRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for EnableTraceEventRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for EnableTraceEventRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/consumer.fbs:47` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `data` in the table `DumpResponse` - pub data: ::planus::alloc::boxed::Box, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`data` field](DumpResponse#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> for DumpResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for DumpResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - DumpResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`data` field](DumpResponse#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_required(0, "DumpResponse", "data") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.data()?, - )?), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `BaseConsumerDump` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `BaseConsumerDump` in the file `../worker/fbs/consumer.fbs:51` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct BaseConsumerDump { - /// The field `id` in the table `BaseConsumerDump` - pub id: ::planus::alloc::string::String, - /// The field `type` in the table `BaseConsumerDump` - pub type_: super::rtp_parameters::Type, - /// The field `producer_id` in the table `BaseConsumerDump` - pub producer_id: ::planus::alloc::string::String, - /// The field `kind` in the table `BaseConsumerDump` - pub kind: super::rtp_parameters::MediaKind, - /// The field `rtp_parameters` in the table `BaseConsumerDump` - pub rtp_parameters: - ::planus::alloc::boxed::Box, - /// The field `consumable_rtp_encodings` in the table `BaseConsumerDump` - pub consumable_rtp_encodings: - ::planus::alloc::vec::Vec, - /// The field `supported_codec_payload_types` in the table `BaseConsumerDump` - pub supported_codec_payload_types: ::planus::alloc::vec::Vec, - /// The field `trace_event_types` in the table `BaseConsumerDump` - pub trace_event_types: ::planus::alloc::vec::Vec, - /// The field `paused` in the table `BaseConsumerDump` - pub paused: bool, - /// The field `producer_paused` in the table `BaseConsumerDump` - pub producer_paused: bool, - /// The field `priority` in the table `BaseConsumerDump` - pub priority: u8, - } - - impl BaseConsumerDump { - /// Creates a [BaseConsumerDumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BaseConsumerDumpBuilder<()> { - BaseConsumerDumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: impl ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_kind: impl ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - field_rtp_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_consumable_rtp_encodings: impl ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - field_supported_codec_payload_types: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[self::TraceEventType]>, - >, - field_paused: impl ::planus::WriteAsDefault, - field_producer_paused: impl ::planus::WriteAsDefault, - field_priority: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); - let prepared_producer_id = field_producer_id.prepare(builder); - let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::Audio); - let prepared_rtp_parameters = field_rtp_parameters.prepare(builder); - let prepared_consumable_rtp_encodings = - field_consumable_rtp_encodings.prepare(builder); - let prepared_supported_codec_payload_types = - field_supported_codec_payload_types.prepare(builder); - let prepared_trace_event_types = field_trace_event_types.prepare(builder); - let prepared_paused = field_paused.prepare(builder, &false); - let prepared_producer_paused = field_producer_paused.prepare(builder, &false); - let prepared_priority = field_priority.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<26> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(2); - table_writer - .write_entry::<::planus::Offset>(4); - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(5); - table_writer.write_entry::<::planus::Offset<[u8]>>(6); - table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(7); - if prepared_type_.is_some() { - table_writer.write_entry::(1); - } - if prepared_kind.is_some() { - table_writer.write_entry::(3); - } - if prepared_paused.is_some() { - table_writer.write_entry::(8); - } - if prepared_producer_paused.is_some() { - table_writer.write_entry::(9); - } - if prepared_priority.is_some() { - table_writer.write_entry::(10); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_producer_id); - object_writer.write::<_, _, 4>(&prepared_rtp_parameters); - object_writer.write::<_, _, 4>(&prepared_consumable_rtp_encodings); - object_writer.write::<_, _, 4>(&prepared_supported_codec_payload_types); - object_writer.write::<_, _, 4>(&prepared_trace_event_types); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - object_writer.write::<_, _, 1>(&prepared_kind); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - if let ::core::option::Option::Some(prepared_producer_paused) = - prepared_producer_paused - { - object_writer.write::<_, _, 1>(&prepared_producer_paused); - } - if let ::core::option::Option::Some(prepared_priority) = - prepared_priority - { - object_writer.write::<_, _, 1>(&prepared_priority); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for BaseConsumerDump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for BaseConsumerDump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for BaseConsumerDump { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - BaseConsumerDump::create( - builder, - &self.id, - self.type_, - &self.producer_id, - self.kind, - &self.rtp_parameters, - &self.consumable_rtp_encodings, - &self.supported_codec_payload_types, - &self.trace_event_types, - self.paused, - self.producer_paused, - self.priority, - ) - } - } - - /// Builder for serializing an instance of the [BaseConsumerDump] type. - /// - /// Can be created using the [BaseConsumerDump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BaseConsumerDumpBuilder(State); - - impl BaseConsumerDumpBuilder<()> { - /// Setter for the [`id` field](BaseConsumerDump#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> BaseConsumerDumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - BaseConsumerDumpBuilder((value,)) - } - } - - impl BaseConsumerDumpBuilder<(T0,)> { - /// Setter for the [`type` field](BaseConsumerDump#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T1) -> BaseConsumerDumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - { - let (v0,) = self.0; - BaseConsumerDumpBuilder((v0, value)) - } - - /// Sets the [`type` field](BaseConsumerDump#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> BaseConsumerDumpBuilder<(T0, ::planus::DefaultValue)> { - self.type_(::planus::DefaultValue) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1)> { - /// Setter for the [`producer_id` field](BaseConsumerDump#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T2) -> BaseConsumerDumpBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - BaseConsumerDumpBuilder((v0, v1, value)) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1, T2)> { - /// Setter for the [`kind` field](BaseConsumerDump#structfield.kind). - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind(self, value: T3) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - { - let (v0, v1, v2) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, value)) - } - - /// Sets the [`kind` field](BaseConsumerDump#structfield.kind) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind_as_default( - self, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.kind(::planus::DefaultValue) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtp_parameters` field](BaseConsumerDump#structfield.rtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_parameters( - self, - value: T4, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, value)) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). - #[inline] - #[allow(clippy::type_complexity)] - pub fn consumable_rtp_encodings( - self, - value: T5, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`supported_codec_payload_types` field](BaseConsumerDump#structfield.supported_codec_payload_types). - #[inline] - #[allow(clippy::type_complexity)] - pub fn supported_codec_payload_types( - self, - value: T6, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`trace_event_types` field](BaseConsumerDump#structfield.trace_event_types). - #[inline] - #[allow(clippy::type_complexity)] - pub fn trace_event_types( - self, - value: T7, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - } - - impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`paused` field](BaseConsumerDump#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T8, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`paused` field](BaseConsumerDump#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl - BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - /// Setter for the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_paused( - self, - value: T9, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - - /// Sets the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_paused_as_default( - self, - ) -> BaseConsumerDumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - ::planus::DefaultValue, - )> { - self.producer_paused(::planus::DefaultValue) - } - } - - impl - BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - /// Setter for the [`priority` field](BaseConsumerDump#structfield.priority). - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority( - self, - value: T10, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`priority` field](BaseConsumerDump#structfield.priority) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority_as_default( - self, - ) -> BaseConsumerDumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - ::planus::DefaultValue, - )> { - self.priority(::planus::DefaultValue) - } - } - - impl - BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BaseConsumerDump]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - T6: ::planus::WriteAs<::planus::Offset<[u8]>>, - T7: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - T6: ::planus::WriteAs<::planus::Offset<[u8]>>, - T7: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - T6: ::planus::WriteAs<::planus::Offset<[u8]>>, - T7: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = &self.0; - BaseConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) - } - } - - /// Reference to a deserialized [BaseConsumerDump]. - #[derive(Copy, Clone)] - pub struct BaseConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BaseConsumerDumpRef<'a> { - /// Getter for the [`id` field](BaseConsumerDump#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "BaseConsumerDump", "id") - } - - /// Getter for the [`type` field](BaseConsumerDump#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "BaseConsumerDump", "type_")? - .unwrap_or(super::rtp_parameters::Type::Simple), - ) - } - - /// Getter for the [`producer_id` field](BaseConsumerDump#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "BaseConsumerDump", "producer_id") - } - - /// Getter for the [`kind` field](BaseConsumerDump#structfield.kind). - #[inline] - pub fn kind(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "BaseConsumerDump", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::Audio), - ) - } - - /// Getter for the [`rtp_parameters` field](BaseConsumerDump#structfield.rtp_parameters). - #[inline] - pub fn rtp_parameters( - &self, - ) -> ::planus::Result> { - self.0 - .access_required(4, "BaseConsumerDump", "rtp_parameters") - } - - /// Getter for the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). - #[inline] - pub fn consumable_rtp_encodings( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::planus::Result>, - >, - > { - self.0 - .access_required(5, "BaseConsumerDump", "consumable_rtp_encodings") - } - - /// Getter for the [`supported_codec_payload_types` field](BaseConsumerDump#structfield.supported_codec_payload_types). - #[inline] - pub fn supported_codec_payload_types(&self) -> ::planus::Result<&'a [u8]> { - self.0 - .access_required(6, "BaseConsumerDump", "supported_codec_payload_types") - } - - /// Getter for the [`trace_event_types` field](BaseConsumerDump#structfield.trace_event_types). - #[inline] - pub fn trace_event_types( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::core::result::Result< - self::TraceEventType, - ::planus::errors::UnknownEnumTag, - >, - >, - > { - self.0 - .access_required(7, "BaseConsumerDump", "trace_event_types") - } - - /// Getter for the [`paused` field](BaseConsumerDump#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(8, "BaseConsumerDump", "paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused). - #[inline] - pub fn producer_paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(9, "BaseConsumerDump", "producer_paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`priority` field](BaseConsumerDump#structfield.priority). - #[inline] - pub fn priority(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(10, "BaseConsumerDump", "priority")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for BaseConsumerDumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BaseConsumerDumpRef"); - f.field("id", &self.id()); - f.field("type_", &self.type_()); - f.field("producer_id", &self.producer_id()); - f.field("kind", &self.kind()); - f.field("rtp_parameters", &self.rtp_parameters()); - f.field("consumable_rtp_encodings", &self.consumable_rtp_encodings()); - f.field( - "supported_codec_payload_types", - &self.supported_codec_payload_types(), - ); - f.field("trace_event_types", &self.trace_event_types()); - f.field("paused", &self.paused()); - f.field("producer_paused", &self.producer_paused()); - f.field("priority", &self.priority()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for BaseConsumerDump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: BaseConsumerDumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - kind: ::core::convert::TryInto::try_into(value.kind()?)?, - rtp_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_parameters()?)?, - ), - consumable_rtp_encodings: value - .consumable_rtp_encodings()? - .to_vec_result()?, - supported_codec_payload_types: value - .supported_codec_payload_types()? - .to_vec(), - trace_event_types: value.trace_event_types()?.to_vec_result()?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - producer_paused: ::core::convert::TryInto::try_into( - value.producer_paused()?, - )?, - priority: ::core::convert::TryInto::try_into(value.priority()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for BaseConsumerDumpRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for BaseConsumerDumpRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[BaseConsumerDumpRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for BaseConsumerDump { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for BaseConsumerDumpRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[BaseConsumerDumpRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConsumerDump` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `ConsumerDump` in the file `../worker/fbs/consumer.fbs:65` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct ConsumerDump { - /// The field `base` in the table `ConsumerDump` - pub base: ::planus::alloc::boxed::Box, - /// The field `rtp_streams` in the table `ConsumerDump` - pub rtp_streams: ::planus::alloc::vec::Vec, - /// The field `preferred_spatial_layer` in the table `ConsumerDump` - pub preferred_spatial_layer: ::core::option::Option, - /// The field `target_spatial_layer` in the table `ConsumerDump` - pub target_spatial_layer: ::core::option::Option, - /// The field `current_spatial_layer` in the table `ConsumerDump` - pub current_spatial_layer: ::core::option::Option, - /// The field `preferred_temporal_layer` in the table `ConsumerDump` - pub preferred_temporal_layer: ::core::option::Option, - /// The field `target_temporal_layer` in the table `ConsumerDump` - pub target_temporal_layer: ::core::option::Option, - /// The field `current_temporal_layer` in the table `ConsumerDump` - pub current_temporal_layer: ::core::option::Option, - } - - impl ConsumerDump { - /// Creates a [ConsumerDumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConsumerDumpBuilder<()> { - ConsumerDumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_rtp_streams: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_preferred_spatial_layer: impl ::planus::WriteAsOptional, - field_target_spatial_layer: impl ::planus::WriteAsOptional, - field_current_spatial_layer: impl ::planus::WriteAsOptional, - field_preferred_temporal_layer: impl ::planus::WriteAsOptional, - field_target_temporal_layer: impl ::planus::WriteAsOptional, - field_current_temporal_layer: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_rtp_streams = field_rtp_streams.prepare(builder); - let prepared_preferred_spatial_layer = - field_preferred_spatial_layer.prepare(builder); - let prepared_target_spatial_layer = field_target_spatial_layer.prepare(builder); - let prepared_current_spatial_layer = - field_current_spatial_layer.prepare(builder); - let prepared_preferred_temporal_layer = - field_preferred_temporal_layer.prepare(builder); - let prepared_target_temporal_layer = - field_target_temporal_layer.prepare(builder); - let prepared_current_temporal_layer = - field_current_temporal_layer.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - if prepared_preferred_spatial_layer.is_some() { - table_writer.write_entry::(2); - } - if prepared_target_spatial_layer.is_some() { - table_writer.write_entry::(3); - } - if prepared_current_spatial_layer.is_some() { - table_writer.write_entry::(4); - } - if prepared_preferred_temporal_layer.is_some() { - table_writer.write_entry::(5); - } - if prepared_target_temporal_layer.is_some() { - table_writer.write_entry::(6); - } - if prepared_current_temporal_layer.is_some() { - table_writer.write_entry::(7); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_rtp_streams); - if let ::core::option::Option::Some(prepared_preferred_spatial_layer) = - prepared_preferred_spatial_layer - { - object_writer.write::<_, _, 2>(&prepared_preferred_spatial_layer); - } - if let ::core::option::Option::Some(prepared_target_spatial_layer) = - prepared_target_spatial_layer - { - object_writer.write::<_, _, 2>(&prepared_target_spatial_layer); - } - if let ::core::option::Option::Some(prepared_current_spatial_layer) = - prepared_current_spatial_layer - { - object_writer.write::<_, _, 2>(&prepared_current_spatial_layer); - } - if let ::core::option::Option::Some(prepared_preferred_temporal_layer) = - prepared_preferred_temporal_layer - { - object_writer.write::<_, _, 2>(&prepared_preferred_temporal_layer); - } - if let ::core::option::Option::Some(prepared_target_temporal_layer) = - prepared_target_temporal_layer - { - object_writer.write::<_, _, 2>(&prepared_target_temporal_layer); - } - if let ::core::option::Option::Some(prepared_current_temporal_layer) = - prepared_current_temporal_layer - { - object_writer.write::<_, _, 2>(&prepared_current_temporal_layer); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConsumerDump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConsumerDump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConsumerDump { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConsumerDump::create( - builder, - &self.base, - &self.rtp_streams, - self.preferred_spatial_layer, - self.target_spatial_layer, - self.current_spatial_layer, - self.preferred_temporal_layer, - self.target_temporal_layer, - self.current_temporal_layer, - ) - } - } - - /// Builder for serializing an instance of the [ConsumerDump] type. - /// - /// Can be created using the [ConsumerDump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConsumerDumpBuilder(State); - - impl ConsumerDumpBuilder<()> { - /// Setter for the [`base` field](ConsumerDump#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> ConsumerDumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConsumerDumpBuilder((value,)) - } - } - - impl ConsumerDumpBuilder<(T0,)> { - /// Setter for the [`rtp_streams` field](ConsumerDump#structfield.rtp_streams). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_streams(self, value: T1) -> ConsumerDumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0,) = self.0; - ConsumerDumpBuilder((v0, value)) - } - } - - impl ConsumerDumpBuilder<(T0, T1)> { - /// Setter for the [`preferred_spatial_layer` field](ConsumerDump#structfield.preferred_spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_spatial_layer( - self, - value: T2, - ) -> ConsumerDumpBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - ConsumerDumpBuilder((v0, v1, value)) - } - - /// Sets the [`preferred_spatial_layer` field](ConsumerDump#structfield.preferred_spatial_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_spatial_layer_as_null(self) -> ConsumerDumpBuilder<(T0, T1, ())> { - self.preferred_spatial_layer(()) - } - } - - impl ConsumerDumpBuilder<(T0, T1, T2)> { - /// Setter for the [`target_spatial_layer` field](ConsumerDump#structfield.target_spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_spatial_layer( - self, - value: T3, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional, - { - let (v0, v1, v2) = self.0; - ConsumerDumpBuilder((v0, v1, v2, value)) - } - - /// Sets the [`target_spatial_layer` field](ConsumerDump#structfield.target_spatial_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_spatial_layer_as_null(self) -> ConsumerDumpBuilder<(T0, T1, T2, ())> { - self.target_spatial_layer(()) - } - } - - impl ConsumerDumpBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`current_spatial_layer` field](ConsumerDump#structfield.current_spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_spatial_layer( - self, - value: T4, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3) = self.0; - ConsumerDumpBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`current_spatial_layer` field](ConsumerDump#structfield.current_spatial_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_spatial_layer_as_null( - self, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, ())> { - self.current_spatial_layer(()) - } - } - - impl ConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`preferred_temporal_layer` field](ConsumerDump#structfield.preferred_temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_temporal_layer( - self, - value: T5, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4) = self.0; - ConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`preferred_temporal_layer` field](ConsumerDump#structfield.preferred_temporal_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_temporal_layer_as_null( - self, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, ())> { - self.preferred_temporal_layer(()) - } - } - - impl ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`target_temporal_layer` field](ConsumerDump#structfield.target_temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_temporal_layer( - self, - value: T6, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - ConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`target_temporal_layer` field](ConsumerDump#structfield.target_temporal_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_temporal_layer_as_null( - self, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, ())> { - self.target_temporal_layer(()) - } - } - - impl ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`current_temporal_layer` field](ConsumerDump#structfield.current_temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_temporal_layer( - self, - value: T7, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - ConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`current_temporal_layer` field](ConsumerDump#structfield.current_temporal_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_temporal_layer_as_null( - self, - ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, ())> { - self.current_temporal_layer(()) - } - } - - impl ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConsumerDump]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional, - T5: ::planus::WriteAsOptional, - T6: ::planus::WriteAsOptional, - T7: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional, - T5: ::planus::WriteAsOptional, - T6: ::planus::WriteAsOptional, - T7: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional, - T5: ::planus::WriteAsOptional, - T6: ::planus::WriteAsOptional, - T7: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - ConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [ConsumerDump]. - #[derive(Copy, Clone)] - pub struct ConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConsumerDumpRef<'a> { - /// Getter for the [`base` field](ConsumerDump#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "ConsumerDump", "base") - } - - /// Getter for the [`rtp_streams` field](ConsumerDump#structfield.rtp_streams). - #[inline] - pub fn rtp_streams( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(1, "ConsumerDump", "rtp_streams") - } - - /// Getter for the [`preferred_spatial_layer` field](ConsumerDump#structfield.preferred_spatial_layer). - #[inline] - pub fn preferred_spatial_layer( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(2, "ConsumerDump", "preferred_spatial_layer") - } - - /// Getter for the [`target_spatial_layer` field](ConsumerDump#structfield.target_spatial_layer). - #[inline] - pub fn target_spatial_layer( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(3, "ConsumerDump", "target_spatial_layer") - } - - /// Getter for the [`current_spatial_layer` field](ConsumerDump#structfield.current_spatial_layer). - #[inline] - pub fn current_spatial_layer( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(4, "ConsumerDump", "current_spatial_layer") - } - - /// Getter for the [`preferred_temporal_layer` field](ConsumerDump#structfield.preferred_temporal_layer). - #[inline] - pub fn preferred_temporal_layer( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(5, "ConsumerDump", "preferred_temporal_layer") - } - - /// Getter for the [`target_temporal_layer` field](ConsumerDump#structfield.target_temporal_layer). - #[inline] - pub fn target_temporal_layer( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(6, "ConsumerDump", "target_temporal_layer") - } - - /// Getter for the [`current_temporal_layer` field](ConsumerDump#structfield.current_temporal_layer). - #[inline] - pub fn current_temporal_layer( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(7, "ConsumerDump", "current_temporal_layer") - } - } - - impl<'a> ::core::fmt::Debug for ConsumerDumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConsumerDumpRef"); - f.field("base", &self.base()); - f.field("rtp_streams", &self.rtp_streams()); - if let ::core::option::Option::Some(field_preferred_spatial_layer) = - self.preferred_spatial_layer().transpose() - { - f.field("preferred_spatial_layer", &field_preferred_spatial_layer); - } - if let ::core::option::Option::Some(field_target_spatial_layer) = - self.target_spatial_layer().transpose() - { - f.field("target_spatial_layer", &field_target_spatial_layer); - } - if let ::core::option::Option::Some(field_current_spatial_layer) = - self.current_spatial_layer().transpose() - { - f.field("current_spatial_layer", &field_current_spatial_layer); - } - if let ::core::option::Option::Some(field_preferred_temporal_layer) = - self.preferred_temporal_layer().transpose() - { - f.field("preferred_temporal_layer", &field_preferred_temporal_layer); - } - if let ::core::option::Option::Some(field_target_temporal_layer) = - self.target_temporal_layer().transpose() - { - f.field("target_temporal_layer", &field_target_temporal_layer); - } - if let ::core::option::Option::Some(field_current_temporal_layer) = - self.current_temporal_layer().transpose() - { - f.field("current_temporal_layer", &field_current_temporal_layer); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConsumerDump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConsumerDumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - rtp_streams: value.rtp_streams()?.to_vec_result()?, - preferred_spatial_layer: if let ::core::option::Option::Some( - preferred_spatial_layer, - ) = value.preferred_spatial_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - preferred_spatial_layer, - )?) - } else { - ::core::option::Option::None - }, - target_spatial_layer: if let ::core::option::Option::Some( - target_spatial_layer, - ) = value.target_spatial_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - target_spatial_layer, - )?) - } else { - ::core::option::Option::None - }, - current_spatial_layer: if let ::core::option::Option::Some( - current_spatial_layer, - ) = value.current_spatial_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - current_spatial_layer, - )?) - } else { - ::core::option::Option::None - }, - preferred_temporal_layer: if let ::core::option::Option::Some( - preferred_temporal_layer, - ) = value.preferred_temporal_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - preferred_temporal_layer, - )?) - } else { - ::core::option::Option::None - }, - target_temporal_layer: if let ::core::option::Option::Some( - target_temporal_layer, - ) = value.target_temporal_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - target_temporal_layer, - )?) - } else { - ::core::option::Option::None - }, - current_temporal_layer: if let ::core::option::Option::Some( - current_temporal_layer, - ) = value.current_temporal_layer()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - current_temporal_layer, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConsumerDumpRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConsumerDumpRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConsumerDumpRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConsumerDump { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConsumerDumpRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConsumerDumpRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/consumer.fbs:76` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `stats` in the table `GetStatsResponse` - pub stats: ::planus::alloc::vec::Vec, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_stats: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_stats = field_stats.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_stats); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create(builder, &self.stats) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`stats` field](GetStatsResponse#structfield.stats). - #[inline] - #[allow(clippy::type_complexity)] - pub fn stats(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - GetStatsResponseBuilder((value,)) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - GetStatsResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`stats` field](GetStatsResponse#structfield.stats). - #[inline] - pub fn stats( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "GetStatsResponse", "stats") - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("stats", &self.stats()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - stats: value.stats()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `LayersChangeNotification` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `LayersChangeNotification` in the file `../worker/fbs/consumer.fbs:82` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct LayersChangeNotification { - /// The field `layers` in the table `LayersChangeNotification` - pub layers: ::planus::alloc::boxed::Box, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for LayersChangeNotification { - fn default() -> Self { - Self { - layers: ::core::default::Default::default(), - } - } - } - - impl LayersChangeNotification { - /// Creates a [LayersChangeNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> LayersChangeNotificationBuilder<()> { - LayersChangeNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_layers: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_layers = field_layers.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_layers); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for LayersChangeNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for LayersChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for LayersChangeNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - LayersChangeNotification::create(builder, &self.layers) - } - } - - /// Builder for serializing an instance of the [LayersChangeNotification] type. - /// - /// Can be created using the [LayersChangeNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct LayersChangeNotificationBuilder(State); - - impl LayersChangeNotificationBuilder<()> { - /// Setter for the [`layers` field](LayersChangeNotification#structfield.layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn layers(self, value: T0) -> LayersChangeNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - LayersChangeNotificationBuilder((value,)) - } - } - - impl LayersChangeNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [LayersChangeNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for LayersChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for LayersChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for LayersChangeNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - LayersChangeNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [LayersChangeNotification]. - #[derive(Copy, Clone)] - pub struct LayersChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> LayersChangeNotificationRef<'a> { - /// Getter for the [`layers` field](LayersChangeNotification#structfield.layers). - #[inline] - pub fn layers(&self) -> ::planus::Result> { - self.0 - .access_required(0, "LayersChangeNotification", "layers") - } - } - - impl<'a> ::core::fmt::Debug for LayersChangeNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("LayersChangeNotificationRef"); - f.field("layers", &self.layers()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for LayersChangeNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: LayersChangeNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - layers: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.layers()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for LayersChangeNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for LayersChangeNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[LayersChangeNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for LayersChangeNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for LayersChangeNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[LayersChangeNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `RtpNotification` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `RtpNotification` in the file `../worker/fbs/consumer.fbs:86` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtpNotification { - /// The field `data` in the table `RtpNotification` - pub data: ::planus::alloc::vec::Vec, - } - - impl RtpNotification { - /// Creates a [RtpNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpNotificationBuilder<()> { - RtpNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u8]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpNotification::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [RtpNotification] type. - /// - /// Can be created using the [RtpNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpNotificationBuilder(State); - - impl RtpNotificationBuilder<()> { - /// Setter for the [`data` field](RtpNotification#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> RtpNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - RtpNotificationBuilder((value,)) - } - } - - impl RtpNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for RtpNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for RtpNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for RtpNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - RtpNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [RtpNotification]. - #[derive(Copy, Clone)] - pub struct RtpNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpNotificationRef<'a> { - /// Getter for the [`data` field](RtpNotification#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "RtpNotification", "data") - } - } - - impl<'a> ::core::fmt::Debug for RtpNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpNotificationRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: value.data()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpNotificationRef]", "read_as_root", 0) - }) - } - } - - /// The table `ScoreNotification` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/consumer.fbs:90` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ScoreNotification { - /// The field `score` in the table `ScoreNotification` - pub score: ::planus::alloc::boxed::Box, - } - - impl ScoreNotification { - /// Creates a [ScoreNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ScoreNotificationBuilder<()> { - ScoreNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_score: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_score = field_score.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_score); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ScoreNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ScoreNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ScoreNotification::create(builder, &self.score) - } - } - - /// Builder for serializing an instance of the [ScoreNotification] type. - /// - /// Can be created using the [ScoreNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ScoreNotificationBuilder(State); - - impl ScoreNotificationBuilder<()> { - /// Setter for the [`score` field](ScoreNotification#structfield.score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn score(self, value: T0) -> ScoreNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ScoreNotificationBuilder((value,)) - } - } - - impl ScoreNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ScoreNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for ScoreNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for ScoreNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ScoreNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [ScoreNotification]. - #[derive(Copy, Clone)] - pub struct ScoreNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ScoreNotificationRef<'a> { - /// Getter for the [`score` field](ScoreNotification#structfield.score). - #[inline] - pub fn score(&self) -> ::planus::Result> { - self.0.access_required(0, "ScoreNotification", "score") - } - } - - impl<'a> ::core::fmt::Debug for ScoreNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ScoreNotificationRef"); - f.field("score", &self.score()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ScoreNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ScoreNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - score: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.score()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ScoreNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ScoreNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ScoreNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ScoreNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ScoreNotificationRef]", "read_as_root", 0) - }) - } - } - - /// The union `TraceInfo` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:94` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub enum TraceInfo { - /// The variant of type `KeyFrameTraceInfo` in the union `TraceInfo` - KeyFrameTraceInfo(::planus::alloc::boxed::Box), - - /// The variant of type `FirTraceInfo` in the union `TraceInfo` - FirTraceInfo(::planus::alloc::boxed::Box), - - /// The variant of type `PliTraceInfo` in the union `TraceInfo` - PliTraceInfo(::planus::alloc::boxed::Box), - - /// The variant of type `RtpTraceInfo` in the union `TraceInfo` - RtpTraceInfo(::planus::alloc::boxed::Box), - } - - impl TraceInfo { - /// Creates a [TraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceInfoBuilder<::planus::Uninitialized> { - TraceInfoBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_key_frame_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_fir_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pli_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtp_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for TraceInfo { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::KeyFrameTraceInfo(value) => { - Self::create_key_frame_trace_info(builder, value) - } - Self::FirTraceInfo(value) => Self::create_fir_trace_info(builder, value), - Self::PliTraceInfo(value) => Self::create_pli_trace_info(builder, value), - Self::RtpTraceInfo(value) => Self::create_rtp_trace_info(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [TraceInfo] type. - /// - /// Can be created using the [TraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TraceInfoBuilder(T); - - impl TraceInfoBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`KeyFrameTraceInfo` variant](TraceInfo#variant.KeyFrameTraceInfo). - #[inline] - pub fn key_frame_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`FirTraceInfo` variant](TraceInfo#variant.FirTraceInfo). - #[inline] - pub fn fir_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PliTraceInfo` variant](TraceInfo#variant.PliTraceInfo). - #[inline] - pub fn pli_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtpTraceInfo` variant](TraceInfo#variant.RtpTraceInfo). - #[inline] - pub fn rtp_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - } - - impl TraceInfoBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [TraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [TraceInfo]. - #[derive(Copy, Clone, Debug)] - pub enum TraceInfoRef<'a> { - KeyFrameTraceInfo(self::KeyFrameTraceInfoRef<'a>), - FirTraceInfo(self::FirTraceInfoRef<'a>), - PliTraceInfo(self::PliTraceInfoRef<'a>), - RtpTraceInfo(self::RtpTraceInfoRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for TraceInfo { - type Error = ::planus::Error; - - fn try_from(value: TraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - TraceInfoRef::KeyFrameTraceInfo(value) => { - Self::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - TraceInfoRef::FirTraceInfo(value) => { - Self::FirTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - TraceInfoRef::PliTraceInfo(value) => { - Self::PliTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - TraceInfoRef::RtpTraceInfo(value) => { - Self::RtpTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for TraceInfoRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::KeyFrameTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::FirTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::PliTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::RtpTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `KeyFrameTraceInfo` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:101` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct KeyFrameTraceInfo { - /// The field `rtp_packet` in the table `KeyFrameTraceInfo` - pub rtp_packet: ::planus::alloc::boxed::Box, - /// The field `is_rtx` in the table `KeyFrameTraceInfo` - pub is_rtx: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for KeyFrameTraceInfo { - fn default() -> Self { - Self { - rtp_packet: ::core::default::Default::default(), - is_rtx: false, - } - } - } - - impl KeyFrameTraceInfo { - /// Creates a [KeyFrameTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> KeyFrameTraceInfoBuilder<()> { - KeyFrameTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_packet: impl ::planus::WriteAs<::planus::Offset>, - field_is_rtx: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_rtp_packet = field_rtp_packet.prepare(builder); - let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_is_rtx.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_packet); - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - object_writer.write::<_, _, 1>(&prepared_is_rtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for KeyFrameTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for KeyFrameTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) - } - } - - /// Builder for serializing an instance of the [KeyFrameTraceInfo] type. - /// - /// Can be created using the [KeyFrameTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct KeyFrameTraceInfoBuilder(State); - - impl KeyFrameTraceInfoBuilder<()> { - /// Setter for the [`rtp_packet` field](KeyFrameTraceInfo#structfield.rtp_packet). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - KeyFrameTraceInfoBuilder((value,)) - } - } - - impl KeyFrameTraceInfoBuilder<(T0,)> { - /// Setter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T1) -> KeyFrameTraceInfoBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - KeyFrameTraceInfoBuilder((v0, value)) - } - - /// Sets the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx_as_default( - self, - ) -> KeyFrameTraceInfoBuilder<(T0, ::planus::DefaultValue)> { - self.is_rtx(::planus::DefaultValue) - } - } - - impl KeyFrameTraceInfoBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [KeyFrameTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for KeyFrameTraceInfoBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - KeyFrameTraceInfo::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [KeyFrameTraceInfo]. - #[derive(Copy, Clone)] - pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> KeyFrameTraceInfoRef<'a> { - /// Getter for the [`rtp_packet` field](KeyFrameTraceInfo#structfield.rtp_packet). - #[inline] - pub fn rtp_packet(&self) -> ::planus::Result> { - self.0.access_required(0, "KeyFrameTraceInfo", "rtp_packet") - } - - /// Getter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). - #[inline] - pub fn is_rtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "KeyFrameTraceInfo", "is_rtx")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for KeyFrameTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("KeyFrameTraceInfoRef"); - f.field("rtp_packet", &self.rtp_packet()); - f.field("is_rtx", &self.is_rtx()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for KeyFrameTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: KeyFrameTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_packet: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_packet()?)?, - ), - is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for KeyFrameTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[KeyFrameTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for KeyFrameTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for KeyFrameTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[KeyFrameTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `FirTraceInfo` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:106` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct FirTraceInfo { - /// The field `ssrc` in the table `FirTraceInfo` - pub ssrc: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for FirTraceInfo { - fn default() -> Self { - Self { ssrc: 0 } - } - } - - impl FirTraceInfo { - /// Creates a [FirTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> FirTraceInfoBuilder<()> { - FirTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for FirTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for FirTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - FirTraceInfo::create(builder, self.ssrc) - } - } - - /// Builder for serializing an instance of the [FirTraceInfo] type. - /// - /// Can be created using the [FirTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct FirTraceInfoBuilder(State); - - impl FirTraceInfoBuilder<()> { - /// Setter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> FirTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - FirTraceInfoBuilder((value,)) - } - - /// Sets the [`ssrc` field](FirTraceInfo#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> FirTraceInfoBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl FirTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [FirTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> for FirTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for FirTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for FirTraceInfoBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - FirTraceInfo::create(builder, v0) - } - } - - /// Reference to a deserialized [FirTraceInfo]. - #[derive(Copy, Clone)] - pub struct FirTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> FirTraceInfoRef<'a> { - /// Getter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "FirTraceInfo", "ssrc")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for FirTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("FirTraceInfoRef"); - f.field("ssrc", &self.ssrc()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for FirTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: FirTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for FirTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for FirTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[FirTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for FirTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for FirTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[FirTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `PliTraceInfo` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:110` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct PliTraceInfo { - /// The field `ssrc` in the table `PliTraceInfo` - pub ssrc: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for PliTraceInfo { - fn default() -> Self { - Self { ssrc: 0 } - } - } - - impl PliTraceInfo { - /// Creates a [PliTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> PliTraceInfoBuilder<()> { - PliTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for PliTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for PliTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PliTraceInfo::create(builder, self.ssrc) - } - } - - /// Builder for serializing an instance of the [PliTraceInfo] type. - /// - /// Can be created using the [PliTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct PliTraceInfoBuilder(State); - - impl PliTraceInfoBuilder<()> { - /// Setter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> PliTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - PliTraceInfoBuilder((value,)) - } - - /// Sets the [`ssrc` field](PliTraceInfo#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> PliTraceInfoBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl PliTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PliTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> for PliTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for PliTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for PliTraceInfoBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - PliTraceInfo::create(builder, v0) - } - } - - /// Reference to a deserialized [PliTraceInfo]. - #[derive(Copy, Clone)] - pub struct PliTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> PliTraceInfoRef<'a> { - /// Getter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "PliTraceInfo", "ssrc")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for PliTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("PliTraceInfoRef"); - f.field("ssrc", &self.ssrc()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for PliTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: PliTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for PliTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for PliTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[PliTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for PliTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for PliTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[PliTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpTraceInfo` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:114` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtpTraceInfo { - /// The field `rtp_packet` in the table `RtpTraceInfo` - pub rtp_packet: ::planus::alloc::boxed::Box, - /// The field `is_rtx` in the table `RtpTraceInfo` - pub is_rtx: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RtpTraceInfo { - fn default() -> Self { - Self { - rtp_packet: ::core::default::Default::default(), - is_rtx: false, - } - } - } - - impl RtpTraceInfo { - /// Creates a [RtpTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpTraceInfoBuilder<()> { - RtpTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_packet: impl ::planus::WriteAs<::planus::Offset>, - field_is_rtx: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_rtp_packet = field_rtp_packet.prepare(builder); - let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_is_rtx.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_packet); - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - object_writer.write::<_, _, 1>(&prepared_is_rtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) - } - } - - /// Builder for serializing an instance of the [RtpTraceInfo] type. - /// - /// Can be created using the [RtpTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpTraceInfoBuilder(State); - - impl RtpTraceInfoBuilder<()> { - /// Setter for the [`rtp_packet` field](RtpTraceInfo#structfield.rtp_packet). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtpTraceInfoBuilder((value,)) - } - } - - impl RtpTraceInfoBuilder<(T0,)> { - /// Setter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T1) -> RtpTraceInfoBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RtpTraceInfoBuilder((v0, value)) - } - - /// Sets the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx_as_default( - self, - ) -> RtpTraceInfoBuilder<(T0, ::planus::DefaultValue)> { - self.is_rtx(::planus::DefaultValue) - } - } - - impl RtpTraceInfoBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for RtpTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for RtpTraceInfoBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - RtpTraceInfo::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [RtpTraceInfo]. - #[derive(Copy, Clone)] - pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpTraceInfoRef<'a> { - /// Getter for the [`rtp_packet` field](RtpTraceInfo#structfield.rtp_packet). - #[inline] - pub fn rtp_packet(&self) -> ::planus::Result> { - self.0.access_required(0, "RtpTraceInfo", "rtp_packet") - } - - /// Getter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). - #[inline] - pub fn is_rtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for RtpTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpTraceInfoRef"); - f.field("rtp_packet", &self.rtp_packet()); - f.field("is_rtx", &self.is_rtx()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_packet: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_packet()?)?, - ), - is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `TraceNotification` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:119` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct TraceNotification { - /// The field `type` in the table `TraceNotification` - pub type_: self::TraceEventType, - /// The field `timestamp` in the table `TraceNotification` - pub timestamp: u64, - /// The field `direction` in the table `TraceNotification` - pub direction: super::common::TraceDirection, - /// The field `info` in the table `TraceNotification` - pub info: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for TraceNotification { - fn default() -> Self { - Self { - type_: self::TraceEventType::Keyframe, - timestamp: 0, - direction: super::common::TraceDirection::DirectionIn, - info: ::core::default::Default::default(), - } - } - } - - impl TraceNotification { - /// Creates a [TraceNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceNotificationBuilder<()> { - TraceNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault< - self::TraceEventType, - self::TraceEventType, - >, - field_timestamp: impl ::planus::WriteAsDefault, - field_direction: impl ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - field_info: impl ::planus::WriteAsOptionalUnion, - ) -> ::planus::Offset { - let prepared_type_ = - field_type_.prepare(builder, &self::TraceEventType::Keyframe); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = field_direction - .prepare(builder, &super::common::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(1); - } - if prepared_info.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_type_.is_some() { - table_writer.write_entry::(0); - } - if prepared_direction.is_some() { - table_writer.write_entry::(2); - } - if prepared_info.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - object_writer.write::<_, _, 4>(&prepared_info.offset()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_direction) = - prepared_direction - { - object_writer.write::<_, _, 1>(&prepared_direction); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - object_writer.write::<_, _, 1>(&prepared_info.tag()); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for TraceNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for TraceNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - TraceNotification::create( - builder, - self.type_, - self.timestamp, - self.direction, - &self.info, - ) - } - } - - /// Builder for serializing an instance of the [TraceNotification] type. - /// - /// Can be created using the [TraceNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TraceNotificationBuilder(State); - - impl TraceNotificationBuilder<()> { - /// Setter for the [`type` field](TraceNotification#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - TraceNotificationBuilder((value,)) - } - - /// Sets the [`type` field](TraceNotification#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> TraceNotificationBuilder<(::planus::DefaultValue,)> { - self.type_(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0,)> { - /// Setter for the [`timestamp` field](TraceNotification#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T1) -> TraceNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - TraceNotificationBuilder((v0, value)) - } - - /// Sets the [`timestamp` field](TraceNotification#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default( - self, - ) -> TraceNotificationBuilder<(T0, ::planus::DefaultValue)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0, T1)> { - /// Setter for the [`direction` field](TraceNotification#structfield.direction). - #[inline] - #[allow(clippy::type_complexity)] - pub fn direction(self, value: T2) -> TraceNotificationBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - { - let (v0, v1) = self.0; - TraceNotificationBuilder((v0, v1, value)) - } - - /// Sets the [`direction` field](TraceNotification#structfield.direction) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn direction_as_default( - self, - ) -> TraceNotificationBuilder<(T0, T1, ::planus::DefaultValue)> { - self.direction(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0, T1, T2)> { - /// Setter for the [`info` field](TraceNotification#structfield.info). - #[inline] - #[allow(clippy::type_complexity)] - pub fn info(self, value: T3) -> TraceNotificationBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptionalUnion, - { - let (v0, v1, v2) = self.0; - TraceNotificationBuilder((v0, v1, v2, value)) - } - - /// Sets the [`info` field](TraceNotification#structfield.info) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn info_as_null(self) -> TraceNotificationBuilder<(T0, T1, T2, ())> { - self.info(()) - } - } - - impl TraceNotificationBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TraceNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAs<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOffset - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - TraceNotification::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [TraceNotification]. - #[derive(Copy, Clone)] - pub struct TraceNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TraceNotificationRef<'a> { - /// Getter for the [`type` field](TraceNotification#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "TraceNotification", "type_")? - .unwrap_or(self::TraceEventType::Keyframe), - ) - } - - /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "TraceNotification", "timestamp")? - .unwrap_or(0), - ) - } - - /// Getter for the [`direction` field](TraceNotification#structfield.direction). - #[inline] - pub fn direction(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "TraceNotification", "direction")? - .unwrap_or(super::common::TraceDirection::DirectionIn), - ) - } - - /// Getter for the [`info` field](TraceNotification#structfield.info). - #[inline] - pub fn info( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access_union(3, "TraceNotification", "info") - } - } - - impl<'a> ::core::fmt::Debug for TraceNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("TraceNotificationRef"); - f.field("type_", &self.type_()); - f.field("timestamp", &self.timestamp()); - f.field("direction", &self.direction()); - if let ::core::option::Option::Some(field_info) = self.info().transpose() { - f.field("info", &field_info); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for TraceNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: TraceNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - direction: ::core::convert::TryInto::try_into(value.direction()?)?, - info: if let ::core::option::Option::Some(info) = value.info()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(info)?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for TraceNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[TraceNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for TraceNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for TraceNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[TraceNotificationRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.RtpPacket` - /// - /// Generated from these locations: - /// * File `../worker/fbs/rtpPacket.fbs` - pub mod rtp_packet { - /// The table `Dump` in the namespace `FBS.RtpPacket` - /// - /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/rtpPacket.fbs:5` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Dump { - /// The field `payload_type` in the table `Dump` - pub payload_type: u8, - /// The field `sequence_number` in the table `Dump` - pub sequence_number: u16, - /// The field `timestamp` in the table `Dump` - pub timestamp: u32, - /// The field `marker` in the table `Dump` - pub marker: bool, - /// The field `ssrc` in the table `Dump` - pub ssrc: u32, - /// The field `is_key_frame` in the table `Dump` - pub is_key_frame: bool, - /// The field `size` in the table `Dump` - pub size: u64, - /// The field `payload_size` in the table `Dump` - pub payload_size: u64, - /// The field `spatial_layer` in the table `Dump` - pub spatial_layer: u8, - /// The field `temporal_layer` in the table `Dump` - pub temporal_layer: u8, - /// The field `mid` in the table `Dump` - pub mid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `rid` in the table `Dump` - pub rid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `rrid` in the table `Dump` - pub rrid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `wide_sequence_number` in the table `Dump` - pub wide_sequence_number: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Dump { - fn default() -> Self { - Self { - payload_type: 0, - sequence_number: 0, - timestamp: 0, - marker: false, - ssrc: 0, - is_key_frame: false, - size: 0, - payload_size: 0, - spatial_layer: 0, - temporal_layer: 0, - mid: ::core::default::Default::default(), - rid: ::core::default::Default::default(), - rrid: ::core::default::Default::default(), - wide_sequence_number: ::core::default::Default::default(), - } - } - } - - impl Dump { - /// Creates a [DumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpBuilder<()> { - DumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_payload_type: impl ::planus::WriteAsDefault, - field_sequence_number: impl ::planus::WriteAsDefault, - field_timestamp: impl ::planus::WriteAsDefault, - field_marker: impl ::planus::WriteAsDefault, - field_ssrc: impl ::planus::WriteAsDefault, - field_is_key_frame: impl ::planus::WriteAsDefault, - field_size: impl ::planus::WriteAsDefault, - field_payload_size: impl ::planus::WriteAsDefault, - field_spatial_layer: impl ::planus::WriteAsDefault, - field_temporal_layer: impl ::planus::WriteAsDefault, - field_mid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_rrid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_wide_sequence_number: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_payload_type = field_payload_type.prepare(builder, &0); - let prepared_sequence_number = field_sequence_number.prepare(builder, &0); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_marker = field_marker.prepare(builder, &false); - let prepared_ssrc = field_ssrc.prepare(builder, &0); - let prepared_is_key_frame = field_is_key_frame.prepare(builder, &false); - let prepared_size = field_size.prepare(builder, &0); - let prepared_payload_size = field_payload_size.prepare(builder, &0); - let prepared_spatial_layer = field_spatial_layer.prepare(builder, &0); - let prepared_temporal_layer = field_temporal_layer.prepare(builder, &0); - let prepared_mid = field_mid.prepare(builder); - let prepared_rid = field_rid.prepare(builder); - let prepared_rrid = field_rrid.prepare(builder); - let prepared_wide_sequence_number = field_wide_sequence_number.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<32> = - ::core::default::Default::default(); - if prepared_size.is_some() { - table_writer.write_entry::(6); - } - if prepared_payload_size.is_some() { - table_writer.write_entry::(7); - } - if prepared_timestamp.is_some() { - table_writer.write_entry::(2); - } - if prepared_ssrc.is_some() { - table_writer.write_entry::(4); - } - if prepared_mid.is_some() { - table_writer.write_entry::<::planus::Offset>(10); - } - if prepared_rid.is_some() { - table_writer.write_entry::<::planus::Offset>(11); - } - if prepared_rrid.is_some() { - table_writer.write_entry::<::planus::Offset>(12); - } - if prepared_sequence_number.is_some() { - table_writer.write_entry::(1); - } - if prepared_wide_sequence_number.is_some() { - table_writer.write_entry::(13); - } - if prepared_payload_type.is_some() { - table_writer.write_entry::(0); - } - if prepared_marker.is_some() { - table_writer.write_entry::(3); - } - if prepared_is_key_frame.is_some() { - table_writer.write_entry::(5); - } - if prepared_spatial_layer.is_some() { - table_writer.write_entry::(8); - } - if prepared_temporal_layer.is_some() { - table_writer.write_entry::(9); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_size) = prepared_size { - object_writer.write::<_, _, 8>(&prepared_size); - } - if let ::core::option::Option::Some(prepared_payload_size) = - prepared_payload_size - { - object_writer.write::<_, _, 8>(&prepared_payload_size); - } - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 4>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_mid) = prepared_mid { - object_writer.write::<_, _, 4>(&prepared_mid); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 4>(&prepared_rid); - } - if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { - object_writer.write::<_, _, 4>(&prepared_rrid); - } - if let ::core::option::Option::Some(prepared_sequence_number) = - prepared_sequence_number - { - object_writer.write::<_, _, 2>(&prepared_sequence_number); - } - if let ::core::option::Option::Some(prepared_wide_sequence_number) = - prepared_wide_sequence_number - { - object_writer.write::<_, _, 2>(&prepared_wide_sequence_number); - } - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - object_writer.write::<_, _, 1>(&prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_marker) = prepared_marker { - object_writer.write::<_, _, 1>(&prepared_marker); - } - if let ::core::option::Option::Some(prepared_is_key_frame) = - prepared_is_key_frame - { - object_writer.write::<_, _, 1>(&prepared_is_key_frame); - } - if let ::core::option::Option::Some(prepared_spatial_layer) = - prepared_spatial_layer - { - object_writer.write::<_, _, 1>(&prepared_spatial_layer); - } - if let ::core::option::Option::Some(prepared_temporal_layer) = - prepared_temporal_layer - { - object_writer.write::<_, _, 1>(&prepared_temporal_layer); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Dump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Dump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Dump { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Dump::create( - builder, - self.payload_type, - self.sequence_number, - self.timestamp, - self.marker, - self.ssrc, - self.is_key_frame, - self.size, - self.payload_size, - self.spatial_layer, - self.temporal_layer, - &self.mid, - &self.rid, - &self.rrid, - self.wide_sequence_number, - ) - } - } - - /// Builder for serializing an instance of the [Dump] type. - /// - /// Can be created using the [Dump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpBuilder(State); - - impl DumpBuilder<()> { - /// Setter for the [`payload_type` field](Dump#structfield.payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type(self, value: T0) -> DumpBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - DumpBuilder((value,)) - } - - /// Sets the [`payload_type` field](Dump#structfield.payload_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type_as_default(self) -> DumpBuilder<(::planus::DefaultValue,)> { - self.payload_type(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0,)> { - /// Setter for the [`sequence_number` field](Dump#structfield.sequence_number). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sequence_number(self, value: T1) -> DumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DumpBuilder((v0, value)) - } - - /// Sets the [`sequence_number` field](Dump#structfield.sequence_number) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sequence_number_as_default( - self, - ) -> DumpBuilder<(T0, ::planus::DefaultValue)> { - self.sequence_number(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1)> { - /// Setter for the [`timestamp` field](Dump#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T2) -> DumpBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - DumpBuilder((v0, v1, value)) - } - - /// Sets the [`timestamp` field](Dump#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default(self) -> DumpBuilder<(T0, T1, ::planus::DefaultValue)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2)> { - /// Setter for the [`marker` field](Dump#structfield.marker). - #[inline] - #[allow(clippy::type_complexity)] - pub fn marker(self, value: T3) -> DumpBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - DumpBuilder((v0, v1, v2, value)) - } - - /// Sets the [`marker` field](Dump#structfield.marker) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn marker_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.marker(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`ssrc` field](Dump#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T4) -> DumpBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - DumpBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`ssrc` field](Dump#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`is_key_frame` field](Dump#structfield.is_key_frame). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_key_frame(self, value: T5) -> DumpBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`is_key_frame` field](Dump#structfield.is_key_frame) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_key_frame_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> { - self.is_key_frame(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`size` field](Dump#structfield.size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn size(self, value: T6) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`size` field](Dump#structfield.size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn size_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> { - self.size(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`payload_size` field](Dump#structfield.payload_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_size( - self, - value: T7, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`payload_size` field](Dump#structfield.payload_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_size_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.payload_size(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`spatial_layer` field](Dump#structfield.spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn spatial_layer( - self, - value: T8, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`spatial_layer` field](Dump#structfield.spatial_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn spatial_layer_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> - { - self.spatial_layer(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`temporal_layer` field](Dump#structfield.temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn temporal_layer( - self, - value: T9, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - - /// Sets the [`temporal_layer` field](Dump#structfield.temporal_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn temporal_layer_as_default( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, ::planus::DefaultValue)> - { - self.temporal_layer(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> { - /// Setter for the [`mid` field](Dump#structfield.mid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid( - self, - value: T10, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`mid` field](Dump#structfield.mid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, ())> { - self.mid(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Setter for the [`rid` field](Dump#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid( - self, - value: T11, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - where - T11: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, value)) - } - - /// Sets the [`rid` field](Dump#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ())> - { - self.rid(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`rrid` field](Dump#structfield.rrid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rrid( - self, - value: T12, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - where - T12: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, value)) - } - - /// Sets the [`rrid` field](Dump#structfield.rrid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rrid_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ())> - { - self.rrid(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - { - /// Setter for the [`wide_sequence_number` field](Dump#structfield.wide_sequence_number). - #[inline] - #[allow(clippy::type_complexity)] - pub fn wide_sequence_number( - self, - value: T13, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - where - T13: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, value)) - } - - /// Sets the [`wide_sequence_number` field](Dump#structfield.wide_sequence_number) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn wide_sequence_number_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ())> - { - self.wide_sequence_number(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Dump]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T11: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T12: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T13: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T11: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T12: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T13: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T11: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T12: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T13: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) = &self.0; - Dump::create( - builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, - ) - } - } - - /// Reference to a deserialized [Dump]. - #[derive(Copy, Clone)] - pub struct DumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpRef<'a> { - /// Getter for the [`payload_type` field](Dump#structfield.payload_type). - #[inline] - pub fn payload_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "Dump", "payload_type")?.unwrap_or(0), - ) - } - - /// Getter for the [`sequence_number` field](Dump#structfield.sequence_number). - #[inline] - pub fn sequence_number(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "Dump", "sequence_number")?.unwrap_or(0), - ) - } - - /// Getter for the [`timestamp` field](Dump#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(2, "Dump", "timestamp")?.unwrap_or(0)) - } - - /// Getter for the [`marker` field](Dump#structfield.marker). - #[inline] - pub fn marker(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(3, "Dump", "marker")?.unwrap_or(false)) - } - - /// Getter for the [`ssrc` field](Dump#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(4, "Dump", "ssrc")?.unwrap_or(0)) - } - - /// Getter for the [`is_key_frame` field](Dump#structfield.is_key_frame). - #[inline] - pub fn is_key_frame(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(5, "Dump", "is_key_frame")?.unwrap_or(false), - ) - } - - /// Getter for the [`size` field](Dump#structfield.size). - #[inline] - pub fn size(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(6, "Dump", "size")?.unwrap_or(0)) - } - - /// Getter for the [`payload_size` field](Dump#structfield.payload_size). - #[inline] - pub fn payload_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(7, "Dump", "payload_size")?.unwrap_or(0), - ) - } - - /// Getter for the [`spatial_layer` field](Dump#structfield.spatial_layer). - #[inline] - pub fn spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(8, "Dump", "spatial_layer")?.unwrap_or(0), - ) - } - - /// Getter for the [`temporal_layer` field](Dump#structfield.temporal_layer). - #[inline] - pub fn temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(9, "Dump", "temporal_layer")?.unwrap_or(0), - ) - } - - /// Getter for the [`mid` field](Dump#structfield.mid). - #[inline] - pub fn mid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(10, "Dump", "mid") - } - - /// Getter for the [`rid` field](Dump#structfield.rid). - #[inline] - pub fn rid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(11, "Dump", "rid") - } - - /// Getter for the [`rrid` field](Dump#structfield.rrid). - #[inline] - pub fn rrid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(12, "Dump", "rrid") - } - - /// Getter for the [`wide_sequence_number` field](Dump#structfield.wide_sequence_number). - #[inline] - pub fn wide_sequence_number( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(13, "Dump", "wide_sequence_number") - } - } - - impl<'a> ::core::fmt::Debug for DumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpRef"); - f.field("payload_type", &self.payload_type()); - f.field("sequence_number", &self.sequence_number()); - f.field("timestamp", &self.timestamp()); - f.field("marker", &self.marker()); - f.field("ssrc", &self.ssrc()); - f.field("is_key_frame", &self.is_key_frame()); - f.field("size", &self.size()); - f.field("payload_size", &self.payload_size()); - f.field("spatial_layer", &self.spatial_layer()); - f.field("temporal_layer", &self.temporal_layer()); - if let ::core::option::Option::Some(field_mid) = self.mid().transpose() { - f.field("mid", &field_mid); - } - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - if let ::core::option::Option::Some(field_rrid) = self.rrid().transpose() { - f.field("rrid", &field_rrid); - } - if let ::core::option::Option::Some(field_wide_sequence_number) = - self.wide_sequence_number().transpose() - { - f.field("wide_sequence_number", &field_wide_sequence_number); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Dump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - payload_type: ::core::convert::TryInto::try_into(value.payload_type()?)?, - sequence_number: ::core::convert::TryInto::try_into( - value.sequence_number()?, - )?, - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - marker: ::core::convert::TryInto::try_into(value.marker()?)?, - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - is_key_frame: ::core::convert::TryInto::try_into(value.is_key_frame()?)?, - size: ::core::convert::TryInto::try_into(value.size()?)?, - payload_size: ::core::convert::TryInto::try_into(value.payload_size()?)?, - spatial_layer: ::core::convert::TryInto::try_into(value.spatial_layer()?)?, - temporal_layer: ::core::convert::TryInto::try_into( - value.temporal_layer()?, - )?, - mid: if let ::core::option::Option::Some(mid) = value.mid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(mid)?) - } else { - ::core::option::Option::None - }, - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - rrid: if let ::core::option::Option::Some(rrid) = value.rrid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rrid)?) - } else { - ::core::option::Option::None - }, - wide_sequence_number: if let ::core::option::Option::Some( - wide_sequence_number, - ) = value.wide_sequence_number()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - wide_sequence_number, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location("[DumpRef]", "get", buffer.offset_from_start) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Dump { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * File `../worker/fbs/rtpParameters.fbs` - pub mod rtp_parameters { - /// The enum `MediaKind` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Enum `MediaKind` in the file `../worker/fbs/rtpParameters.fbs:3` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum MediaKind { - /// The variant `AUDIO` in the enum `MediaKind` - Audio = 0, - - /// The variant `VIDEO` in the enum `MediaKind` - Video = 1, - } - - impl MediaKind { - /// Array containing all valid variants of MediaKind - pub const ENUM_VALUES: [Self; 2] = [Self::Audio, Self::Video]; - } - - impl ::core::convert::TryFrom for MediaKind { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(MediaKind::Audio), - 1 => ::core::result::Result::Ok(MediaKind::Video), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: MediaKind) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for MediaKind { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for MediaKind { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for MediaKind { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> MediaKind { - *self - } - } - - impl ::planus::WriteAsDefault for MediaKind { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &MediaKind, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for MediaKind { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for MediaKind { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for MediaKind { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "MediaKind", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for MediaKind { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The enum `Type` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Enum `Type` in the file `../worker/fbs/rtpParameters.fbs:8` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum Type { - /// The variant `SIMPLE` in the enum `Type` - Simple = 0, - - /// The variant `SIMULCAST` in the enum `Type` - Simulcast = 1, - - /// The variant `SVC` in the enum `Type` - Svc = 2, - - /// The variant `PIPE` in the enum `Type` - Pipe = 3, - } - - impl Type { - /// Array containing all valid variants of Type - pub const ENUM_VALUES: [Self; 4] = - [Self::Simple, Self::Simulcast, Self::Svc, Self::Pipe]; - } - - impl ::core::convert::TryFrom for Type { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(Type::Simple), - 1 => ::core::result::Result::Ok(Type::Simulcast), - 2 => ::core::result::Result::Ok(Type::Svc), - 3 => ::core::result::Result::Ok(Type::Pipe), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: Type) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for Type { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for Type { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for Type { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { - *self - } - } - - impl ::planus::WriteAsDefault for Type { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &Type, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for Type { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for Type { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for Type { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "Type", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for Type { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `Boolean` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `Boolean` in the file `../worker/fbs/rtpParameters.fbs:16` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Boolean { - /// The field `value` in the table `Boolean` - pub value: u8, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Boolean { - fn default() -> Self { - Self { value: 0 } - } - } - - impl Boolean { - /// Creates a [BooleanBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BooleanBuilder<()> { - BooleanBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_value.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 1>(&prepared_value); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Boolean { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Boolean { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Boolean { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Boolean::create(builder, self.value) - } - } - - /// Builder for serializing an instance of the [Boolean] type. - /// - /// Can be created using the [Boolean::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BooleanBuilder(State); - - impl BooleanBuilder<()> { - /// Setter for the [`value` field](Boolean#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> BooleanBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - BooleanBuilder((value,)) - } - - /// Sets the [`value` field](Boolean#structfield.value) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_default(self) -> BooleanBuilder<(::planus::DefaultValue,)> { - self.value(::planus::DefaultValue) - } - } - - impl BooleanBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Boolean]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> ::planus::WriteAs<::planus::Offset> - for BooleanBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> for BooleanBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for BooleanBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Boolean::create(builder, v0) - } - } - - /// Reference to a deserialized [Boolean]. - #[derive(Copy, Clone)] - pub struct BooleanRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BooleanRef<'a> { - /// Getter for the [`value` field](Boolean#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Boolean", "value")?.unwrap_or(0)) - } - } - - impl<'a> ::core::fmt::Debug for BooleanRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BooleanRef"); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Boolean { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: BooleanRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for BooleanRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for BooleanRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[BooleanRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Boolean { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for BooleanRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[BooleanRef]", "read_as_root", 0) - }) - } - } - - /// The table `Integer32` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `Integer32` in the file `../worker/fbs/rtpParameters.fbs:20` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Integer32 { - /// The field `value` in the table `Integer32` - pub value: i32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Integer32 { - fn default() -> Self { - Self { value: 0 } - } - } - - impl Integer32 { - /// Creates a [Integer32Builder] for serializing an instance of this table. - #[inline] - pub fn builder() -> Integer32Builder<()> { - Integer32Builder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_value.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 4>(&prepared_value); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Integer32 { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Integer32 { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Integer32 { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Integer32::create(builder, self.value) - } - } - - /// Builder for serializing an instance of the [Integer32] type. - /// - /// Can be created using the [Integer32::builder] method. - #[derive(Debug)] - #[must_use] - pub struct Integer32Builder(State); - - impl Integer32Builder<()> { - /// Setter for the [`value` field](Integer32#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> Integer32Builder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - Integer32Builder((value,)) - } - - /// Sets the [`value` field](Integer32#structfield.value) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_default(self) -> Integer32Builder<(::planus::DefaultValue,)> { - self.value(::planus::DefaultValue) - } - } - - impl Integer32Builder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Integer32]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> for Integer32Builder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> for Integer32Builder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for Integer32Builder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Integer32::create(builder, v0) - } - } - - /// Reference to a deserialized [Integer32]. - #[derive(Copy, Clone)] - pub struct Integer32Ref<'a>(::planus::table_reader::Table<'a>); - - impl<'a> Integer32Ref<'a> { - /// Getter for the [`value` field](Integer32#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Integer32", "value")?.unwrap_or(0)) - } - } - - impl<'a> ::core::fmt::Debug for Integer32Ref<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("Integer32Ref"); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Integer32 { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: Integer32Ref<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for Integer32Ref<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for Integer32Ref<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[Integer32Ref]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Integer32 { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for Integer32Ref<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[Integer32Ref]", "read_as_root", 0) - }) - } - } - - /// The table `Integer32Array` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `Integer32Array` in the file `../worker/fbs/rtpParameters.fbs:24` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Integer32Array { - /// The field `value` in the table `Integer32Array` - pub value: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Integer32Array { - fn default() -> Self { - Self { - value: ::core::default::Default::default(), - } - } - } - - impl Integer32Array { - /// Creates a [Integer32ArrayBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> Integer32ArrayBuilder<()> { - Integer32ArrayBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAsOptional<::planus::Offset<[i32]>>, - ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_value.is_some() { - table_writer.write_entry::<::planus::Offset<[i32]>>(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 4>(&prepared_value); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Integer32Array { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Integer32Array { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Integer32Array { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - Integer32Array::create(builder, &self.value) - } - } - - /// Builder for serializing an instance of the [Integer32Array] type. - /// - /// Can be created using the [Integer32Array::builder] method. - #[derive(Debug)] - #[must_use] - pub struct Integer32ArrayBuilder(State); - - impl Integer32ArrayBuilder<()> { - /// Setter for the [`value` field](Integer32Array#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> Integer32ArrayBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset<[i32]>>, - { - Integer32ArrayBuilder((value,)) - } - - /// Sets the [`value` field](Integer32Array#structfield.value) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_null(self) -> Integer32ArrayBuilder<((),)> { - self.value(()) - } - } - - impl Integer32ArrayBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Integer32Array]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for Integer32ArrayBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for Integer32ArrayBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for Integer32ArrayBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - Integer32Array::create(builder, v0) - } - } - - /// Reference to a deserialized [Integer32Array]. - #[derive(Copy, Clone)] - pub struct Integer32ArrayRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> Integer32ArrayRef<'a> { - /// Getter for the [`value` field](Integer32Array#structfield.value). - #[inline] - pub fn value( - &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i32>>> - { - self.0.access(0, "Integer32Array", "value") - } - } - - impl<'a> ::core::fmt::Debug for Integer32ArrayRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("Integer32ArrayRef"); - if let ::core::option::Option::Some(field_value) = self.value().transpose() { - f.field("value", &field_value); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Integer32Array { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: Integer32ArrayRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - value: if let ::core::option::Option::Some(value) = value.value()? { - ::core::option::Option::Some(value.to_vec()?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for Integer32ArrayRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for Integer32ArrayRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[Integer32ArrayRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Integer32Array { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for Integer32ArrayRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[Integer32ArrayRef]", "read_as_root", 0) - }) - } - } - - /// The table `Double` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `Double` in the file `../worker/fbs/rtpParameters.fbs:28` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Double { - /// The field `value` in the table `Double` - pub value: f64, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Double { - fn default() -> Self { - Self { value: 0.0 } - } - } - - impl Double { - /// Creates a [DoubleBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DoubleBuilder<()> { - DoubleBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder, &0.0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_value.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 8>(&prepared_value); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Double { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Double { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Double { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Double::create(builder, self.value) - } - } - - /// Builder for serializing an instance of the [Double] type. - /// - /// Can be created using the [Double::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DoubleBuilder(State); - - impl DoubleBuilder<()> { - /// Setter for the [`value` field](Double#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> DoubleBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - DoubleBuilder((value,)) - } - - /// Sets the [`value` field](Double#structfield.value) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_default(self) -> DoubleBuilder<(::planus::DefaultValue,)> { - self.value(::planus::DefaultValue) - } - } - - impl DoubleBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Double]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> ::planus::WriteAs<::planus::Offset> - for DoubleBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> for DoubleBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for DoubleBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Double::create(builder, v0) - } - } - - /// Reference to a deserialized [Double]. - #[derive(Copy, Clone)] - pub struct DoubleRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DoubleRef<'a> { - /// Getter for the [`value` field](Double#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Double", "value")?.unwrap_or(0.0)) - } - } - - impl<'a> ::core::fmt::Debug for DoubleRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DoubleRef"); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Double { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DoubleRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DoubleRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DoubleRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DoubleRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Double { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DoubleRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DoubleRef]", "read_as_root", 0) - }) - } - } - - /// The table `String` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/rtpParameters.fbs:32` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct String { - /// The field `value` in the table `String` - pub value: ::planus::alloc::string::String, - } - - impl String { - /// Creates a [StringBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StringBuilder<()> { - StringBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for String { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for String { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for String { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - String::create(builder, &self.value) - } - } - - /// Builder for serializing an instance of the [String] type. - /// - /// Can be created using the [String::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StringBuilder(State); - - impl StringBuilder<()> { - /// Setter for the [`value` field](String#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> StringBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - StringBuilder((value,)) - } - } - - impl StringBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [String]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> for StringBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> for StringBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> ::planus::WriteAsOffset - for StringBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - String::create(builder, v0) - } - } - - /// Reference to a deserialized [String]. - #[derive(Copy, Clone)] - pub struct StringRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> StringRef<'a> { - /// Getter for the [`value` field](String#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "String", "value") - } - } - - impl<'a> ::core::fmt::Debug for StringRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("StringRef"); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for String { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: StringRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for StringRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for StringRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[StringRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for String { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for StringRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[StringRef]", "read_as_root", 0) - }) - } - } - - /// The union `Value` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Union `Value` in the file `../worker/fbs/rtpParameters.fbs:36` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub enum Value { - /// The variant of type `Boolean` in the union `Value` - Boolean(::planus::alloc::boxed::Box), - - /// The variant of type `Integer32` in the union `Value` - Integer32(::planus::alloc::boxed::Box), - - /// The variant of type `Double` in the union `Value` - Double(::planus::alloc::boxed::Box), - - /// The variant of type `String` in the union `Value` - String(::planus::alloc::boxed::Box), - - /// The variant of type `Integer32Array` in the union `Value` - Integer32Array(::planus::alloc::boxed::Box), - } - - impl Value { - /// Creates a [ValueBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ValueBuilder<::planus::Uninitialized> { - ValueBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_boolean( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_integer32( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_double( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_string( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_integer32_array( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for Value { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::Boolean(value) => Self::create_boolean(builder, value), - Self::Integer32(value) => Self::create_integer32(builder, value), - Self::Double(value) => Self::create_double(builder, value), - Self::String(value) => Self::create_string(builder, value), - Self::Integer32Array(value) => Self::create_integer32_array(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for Value { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [Value] type. - /// - /// Can be created using the [Value::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ValueBuilder(T); - - impl ValueBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`Boolean` variant](Value#variant.Boolean). - #[inline] - pub fn boolean(self, value: T) -> ValueBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - ValueBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Integer32` variant](Value#variant.Integer32). - #[inline] - pub fn integer32(self, value: T) -> ValueBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - ValueBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Double` variant](Value#variant.Double). - #[inline] - pub fn double(self, value: T) -> ValueBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - ValueBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`String` variant](Value#variant.String). - #[inline] - pub fn string(self, value: T) -> ValueBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - ValueBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Integer32Array` variant](Value#variant.Integer32Array). - #[inline] - pub fn integer32_array( - self, - value: T, - ) -> ValueBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - ValueBuilder(::planus::Initialized(value)) - } - } - - impl ValueBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Value]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [Value]. - #[derive(Copy, Clone, Debug)] - pub enum ValueRef<'a> { - Boolean(self::BooleanRef<'a>), - Integer32(self::Integer32Ref<'a>), - Double(self::DoubleRef<'a>), - String(self::StringRef<'a>), - Integer32Array(self::Integer32ArrayRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for Value { - type Error = ::planus::Error; - - fn try_from(value: ValueRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - ValueRef::Boolean(value) => { - Self::Boolean(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - ValueRef::Integer32(value) => { - Self::Integer32(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - ValueRef::Double(value) => Self::Double(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), - - ValueRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), - - ValueRef::Integer32Array(value) => { - Self::Integer32Array(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for ValueRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::Boolean( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::Integer32( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::Double( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::String( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::Integer32Array( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `Parameter` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `Parameter` in the file `../worker/fbs/rtpParameters.fbs:44` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Parameter { - /// The field `name` in the table `Parameter` - pub name: ::planus::alloc::string::String, - /// The field `value` in the table `Parameter` - pub value: self::Value, - } - - impl Parameter { - /// Creates a [ParameterBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ParameterBuilder<()> { - ParameterBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_name: impl ::planus::WriteAs<::planus::Offset>, - field_value: impl ::planus::WriteAsUnion, - ) -> ::planus::Offset { - let prepared_name = field_name.prepare(builder); - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(2); - table_writer.write_entry::(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_name); - object_writer.write::<_, _, 4>(&prepared_value.offset()); - object_writer.write::<_, _, 1>(&prepared_value.tag()); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Parameter { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Parameter { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Parameter { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Parameter::create(builder, &self.name, &self.value) - } - } - - /// Builder for serializing an instance of the [Parameter] type. - /// - /// Can be created using the [Parameter::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ParameterBuilder(State); - - impl ParameterBuilder<()> { - /// Setter for the [`name` field](Parameter#structfield.name). - #[inline] - #[allow(clippy::type_complexity)] - pub fn name(self, value: T0) -> ParameterBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ParameterBuilder((value,)) - } - } - - impl ParameterBuilder<(T0,)> { - /// Setter for the [`value` field](Parameter#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> ParameterBuilder<(T0, T1)> - where - T1: ::planus::WriteAsUnion, - { - let (v0,) = self.0; - ParameterBuilder((v0, value)) - } - } - - impl ParameterBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Parameter]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAs<::planus::Offset> for ParameterBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for ParameterBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOffset for ParameterBuilder<(T0, T1)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - Parameter::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [Parameter]. - #[derive(Copy, Clone)] - pub struct ParameterRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ParameterRef<'a> { - /// Getter for the [`name` field](Parameter#structfield.name). - #[inline] - pub fn name(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Parameter", "name") - } - - /// Getter for the [`value` field](Parameter#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result> { - self.0.access_union_required(1, "Parameter", "value") - } - } - - impl<'a> ::core::fmt::Debug for ParameterRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ParameterRef"); - f.field("name", &self.name()); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Parameter { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ParameterRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - name: ::core::convert::TryInto::try_into(value.name()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ParameterRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ParameterRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ParameterRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Parameter { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ParameterRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ParameterRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtcpFeedback` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtcpFeedback` in the file `../worker/fbs/rtpParameters.fbs:49` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtcpFeedback { - /// The field `type` in the table `RtcpFeedback` - pub type_: ::planus::alloc::string::String, - /// The field `parameter` in the table `RtcpFeedback` - pub parameter: ::core::option::Option<::planus::alloc::string::String>, - } - - impl RtcpFeedback { - /// Creates a [RtcpFeedbackBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtcpFeedbackBuilder<()> { - RtcpFeedbackBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAs<::planus::Offset>, - field_parameter: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder); - let prepared_parameter = field_parameter.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_parameter.is_some() { - table_writer.write_entry::<::planus::Offset>(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_type_); - if let ::core::option::Option::Some(prepared_parameter) = - prepared_parameter - { - object_writer.write::<_, _, 4>(&prepared_parameter); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtcpFeedback { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtcpFeedback { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtcpFeedback { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtcpFeedback::create(builder, &self.type_, &self.parameter) - } - } - - /// Builder for serializing an instance of the [RtcpFeedback] type. - /// - /// Can be created using the [RtcpFeedback::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtcpFeedbackBuilder(State); - - impl RtcpFeedbackBuilder<()> { - /// Setter for the [`type` field](RtcpFeedback#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> RtcpFeedbackBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtcpFeedbackBuilder((value,)) - } - } - - impl RtcpFeedbackBuilder<(T0,)> { - /// Setter for the [`parameter` field](RtcpFeedback#structfield.parameter). - #[inline] - #[allow(clippy::type_complexity)] - pub fn parameter(self, value: T1) -> RtcpFeedbackBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0,) = self.0; - RtcpFeedbackBuilder((v0, value)) - } - - /// Sets the [`parameter` field](RtcpFeedback#structfield.parameter) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn parameter_as_null(self) -> RtcpFeedbackBuilder<(T0, ())> { - self.parameter(()) - } - } - - impl RtcpFeedbackBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtcpFeedback]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAs<::planus::Offset> - for RtcpFeedbackBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOptional<::planus::Offset> - for RtcpFeedbackBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOffset for RtcpFeedbackBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - RtcpFeedback::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [RtcpFeedback]. - #[derive(Copy, Clone)] - pub struct RtcpFeedbackRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtcpFeedbackRef<'a> { - /// Getter for the [`type` field](RtcpFeedback#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "RtcpFeedback", "type_") - } - - /// Getter for the [`parameter` field](RtcpFeedback#structfield.parameter). - #[inline] - pub fn parameter( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(1, "RtcpFeedback", "parameter") - } - } - - impl<'a> ::core::fmt::Debug for RtcpFeedbackRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtcpFeedbackRef"); - f.field("type_", &self.type_()); - if let ::core::option::Option::Some(field_parameter) = - self.parameter().transpose() - { - f.field("parameter", &field_parameter); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtcpFeedback { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtcpFeedbackRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - parameter: if let ::core::option::Option::Some(parameter) = - value.parameter()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - parameter, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtcpFeedbackRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtcpFeedbackRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtcpFeedbackRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtcpFeedback { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtcpFeedbackRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtcpFeedbackRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpCodecParameters` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtpCodecParameters` in the file `../worker/fbs/rtpParameters.fbs:55` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct RtpCodecParameters { - /// The field `mime_type` in the table `RtpCodecParameters` - pub mime_type: ::planus::alloc::string::String, - /// The field `payload_type` in the table `RtpCodecParameters` - pub payload_type: u8, - /// The field `clock_rate` in the table `RtpCodecParameters` - pub clock_rate: u32, - /// The field `channels` in the table `RtpCodecParameters` - pub channels: ::core::option::Option, - /// The field `parameters` in the table `RtpCodecParameters` - pub parameters: ::core::option::Option<::planus::alloc::vec::Vec>, - /// The field `rtcp_feedback` in the table `RtpCodecParameters` - pub rtcp_feedback: - ::core::option::Option<::planus::alloc::vec::Vec>, - } - - impl RtpCodecParameters { - /// Creates a [RtpCodecParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpCodecParametersBuilder<()> { - RtpCodecParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_mime_type: impl ::planus::WriteAs<::planus::Offset>, - field_payload_type: impl ::planus::WriteAsDefault, - field_clock_rate: impl ::planus::WriteAsDefault, - field_channels: impl ::planus::WriteAsOptional, - field_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - field_rtcp_feedback: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_mime_type = field_mime_type.prepare(builder); - let prepared_payload_type = field_payload_type.prepare(builder, &0); - let prepared_clock_rate = field_clock_rate.prepare(builder, &0); - let prepared_channels = field_channels.prepare(builder); - let prepared_parameters = field_parameters.prepare(builder); - let prepared_rtcp_feedback = field_rtcp_feedback.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_clock_rate.is_some() { - table_writer.write_entry::(2); - } - if prepared_parameters.is_some() { - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>( - 4, - ); - } - if prepared_rtcp_feedback.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); - } - if prepared_payload_type.is_some() { - table_writer.write_entry::(1); - } - if prepared_channels.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_mime_type); - if let ::core::option::Option::Some(prepared_clock_rate) = - prepared_clock_rate - { - object_writer.write::<_, _, 4>(&prepared_clock_rate); - } - if let ::core::option::Option::Some(prepared_parameters) = - prepared_parameters - { - object_writer.write::<_, _, 4>(&prepared_parameters); - } - if let ::core::option::Option::Some(prepared_rtcp_feedback) = - prepared_rtcp_feedback - { - object_writer.write::<_, _, 4>(&prepared_rtcp_feedback); - } - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - object_writer.write::<_, _, 1>(&prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_channels) = - prepared_channels - { - object_writer.write::<_, _, 1>(&prepared_channels); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpCodecParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpCodecParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpCodecParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpCodecParameters::create( - builder, - &self.mime_type, - self.payload_type, - self.clock_rate, - self.channels, - &self.parameters, - &self.rtcp_feedback, - ) - } - } - - /// Builder for serializing an instance of the [RtpCodecParameters] type. - /// - /// Can be created using the [RtpCodecParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpCodecParametersBuilder(State); - - impl RtpCodecParametersBuilder<()> { - /// Setter for the [`mime_type` field](RtpCodecParameters#structfield.mime_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mime_type(self, value: T0) -> RtpCodecParametersBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtpCodecParametersBuilder((value,)) - } - } - - impl RtpCodecParametersBuilder<(T0,)> { - /// Setter for the [`payload_type` field](RtpCodecParameters#structfield.payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type(self, value: T1) -> RtpCodecParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RtpCodecParametersBuilder((v0, value)) - } - - /// Sets the [`payload_type` field](RtpCodecParameters#structfield.payload_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type_as_default( - self, - ) -> RtpCodecParametersBuilder<(T0, ::planus::DefaultValue)> { - self.payload_type(::planus::DefaultValue) - } - } - - impl RtpCodecParametersBuilder<(T0, T1)> { - /// Setter for the [`clock_rate` field](RtpCodecParameters#structfield.clock_rate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn clock_rate(self, value: T2) -> RtpCodecParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - RtpCodecParametersBuilder((v0, v1, value)) - } - - /// Sets the [`clock_rate` field](RtpCodecParameters#structfield.clock_rate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn clock_rate_as_default( - self, - ) -> RtpCodecParametersBuilder<(T0, T1, ::planus::DefaultValue)> { - self.clock_rate(::planus::DefaultValue) - } - } - - impl RtpCodecParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`channels` field](RtpCodecParameters#structfield.channels). - #[inline] - #[allow(clippy::type_complexity)] - pub fn channels(self, value: T3) -> RtpCodecParametersBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional, - { - let (v0, v1, v2) = self.0; - RtpCodecParametersBuilder((v0, v1, v2, value)) - } - - /// Sets the [`channels` field](RtpCodecParameters#structfield.channels) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn channels_as_null(self) -> RtpCodecParametersBuilder<(T0, T1, T2, ())> { - self.channels(()) - } - } - - impl RtpCodecParametersBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`parameters` field](RtpCodecParameters#structfield.parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn parameters( - self, - value: T4, - ) -> RtpCodecParametersBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3) = self.0; - RtpCodecParametersBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`parameters` field](RtpCodecParameters#structfield.parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn parameters_as_null(self) -> RtpCodecParametersBuilder<(T0, T1, T2, T3, ())> { - self.parameters(()) - } - } - - impl RtpCodecParametersBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`rtcp_feedback` field](RtpCodecParameters#structfield.rtcp_feedback). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_feedback( - self, - value: T5, - ) -> RtpCodecParametersBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - RtpCodecParametersBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`rtcp_feedback` field](RtpCodecParameters#structfield.rtcp_feedback) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_feedback_as_null( - self, - ) -> RtpCodecParametersBuilder<(T0, T1, T2, T3, T4, ())> { - self.rtcp_feedback(()) - } - } - - impl RtpCodecParametersBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpCodecParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for RtpCodecParametersBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpCodecParametersBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset - for RtpCodecParametersBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - RtpCodecParameters::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [RtpCodecParameters]. - #[derive(Copy, Clone)] - pub struct RtpCodecParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpCodecParametersRef<'a> { - /// Getter for the [`mime_type` field](RtpCodecParameters#structfield.mime_type). - #[inline] - pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "RtpCodecParameters", "mime_type") - } - - /// Getter for the [`payload_type` field](RtpCodecParameters#structfield.payload_type). - #[inline] - pub fn payload_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "RtpCodecParameters", "payload_type")? - .unwrap_or(0), - ) - } - - /// Getter for the [`clock_rate` field](RtpCodecParameters#structfield.clock_rate). - #[inline] - pub fn clock_rate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "RtpCodecParameters", "clock_rate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`channels` field](RtpCodecParameters#structfield.channels). - #[inline] - pub fn channels(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(3, "RtpCodecParameters", "channels") - } - - /// Getter for the [`parameters` field](RtpCodecParameters#structfield.parameters). - #[inline] - pub fn parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(4, "RtpCodecParameters", "parameters") - } - - /// Getter for the [`rtcp_feedback` field](RtpCodecParameters#structfield.rtcp_feedback). - #[inline] - pub fn rtcp_feedback( - &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(5, "RtpCodecParameters", "rtcp_feedback") - } - } - - impl<'a> ::core::fmt::Debug for RtpCodecParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpCodecParametersRef"); - f.field("mime_type", &self.mime_type()); - f.field("payload_type", &self.payload_type()); - f.field("clock_rate", &self.clock_rate()); - if let ::core::option::Option::Some(field_channels) = - self.channels().transpose() - { - f.field("channels", &field_channels); - } - if let ::core::option::Option::Some(field_parameters) = - self.parameters().transpose() - { - f.field("parameters", &field_parameters); - } - if let ::core::option::Option::Some(field_rtcp_feedback) = - self.rtcp_feedback().transpose() - { - f.field("rtcp_feedback", &field_rtcp_feedback); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpCodecParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpCodecParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - mime_type: ::core::convert::TryInto::try_into(value.mime_type()?)?, - payload_type: ::core::convert::TryInto::try_into(value.payload_type()?)?, - clock_rate: ::core::convert::TryInto::try_into(value.clock_rate()?)?, - channels: if let ::core::option::Option::Some(channels) = - value.channels()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - channels, - )?) - } else { - ::core::option::Option::None - }, - parameters: if let ::core::option::Option::Some(parameters) = - value.parameters()? - { - ::core::option::Option::Some(parameters.to_vec_result()?) - } else { - ::core::option::Option::None - }, - rtcp_feedback: if let ::core::option::Option::Some(rtcp_feedback) = - value.rtcp_feedback()? - { - ::core::option::Option::Some(rtcp_feedback.to_vec_result()?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpCodecParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpCodecParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpCodecParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpCodecParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpCodecParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpCodecParametersRef]", "read_as_root", 0) - }) - } - } - - /// The enum `RtpHeaderExtensionUri` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Enum `RtpHeaderExtensionUri` in the file `../worker/fbs/rtpParameters.fbs:64` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum RtpHeaderExtensionUri { - /// The variant `Mid` in the enum `RtpHeaderExtensionUri` - Mid = 0, - - /// The variant `RtpStreamId` in the enum `RtpHeaderExtensionUri` - RtpStreamId = 1, - - /// The variant `RepairRtpStreamId` in the enum `RtpHeaderExtensionUri` - RepairRtpStreamId = 2, - - /// The variant `FrameMarkingDraft07` in the enum `RtpHeaderExtensionUri` - FrameMarkingDraft07 = 3, - - /// The variant `FrameMarking` in the enum `RtpHeaderExtensionUri` - FrameMarking = 4, - - /// The variant `AudioLevel` in the enum `RtpHeaderExtensionUri` - AudioLevel = 5, - - /// The variant `VideoOrientation` in the enum `RtpHeaderExtensionUri` - VideoOrientation = 6, - - /// The variant `TimeOffset` in the enum `RtpHeaderExtensionUri` - TimeOffset = 7, - - /// The variant `TransportWideCcDraft01` in the enum `RtpHeaderExtensionUri` - TransportWideCcDraft01 = 8, - - /// The variant `AbsSendTime` in the enum `RtpHeaderExtensionUri` - AbsSendTime = 9, - - /// The variant `AbsCaptureTime` in the enum `RtpHeaderExtensionUri` - AbsCaptureTime = 10, - } - - impl RtpHeaderExtensionUri { - /// Array containing all valid variants of RtpHeaderExtensionUri - pub const ENUM_VALUES: [Self; 11] = [ - Self::Mid, - Self::RtpStreamId, - Self::RepairRtpStreamId, - Self::FrameMarkingDraft07, - Self::FrameMarking, - Self::AudioLevel, - Self::VideoOrientation, - Self::TimeOffset, - Self::TransportWideCcDraft01, - Self::AbsSendTime, - Self::AbsCaptureTime, - ]; - } - - impl ::core::convert::TryFrom for RtpHeaderExtensionUri { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(RtpHeaderExtensionUri::Mid), - 1 => ::core::result::Result::Ok(RtpHeaderExtensionUri::RtpStreamId), - 2 => ::core::result::Result::Ok(RtpHeaderExtensionUri::RepairRtpStreamId), - 3 => ::core::result::Result::Ok(RtpHeaderExtensionUri::FrameMarkingDraft07), - 4 => ::core::result::Result::Ok(RtpHeaderExtensionUri::FrameMarking), - 5 => ::core::result::Result::Ok(RtpHeaderExtensionUri::AudioLevel), - 6 => ::core::result::Result::Ok(RtpHeaderExtensionUri::VideoOrientation), - 7 => ::core::result::Result::Ok(RtpHeaderExtensionUri::TimeOffset), - 8 => ::core::result::Result::Ok( - RtpHeaderExtensionUri::TransportWideCcDraft01, - ), - 9 => ::core::result::Result::Ok(RtpHeaderExtensionUri::AbsSendTime), - 10 => ::core::result::Result::Ok(RtpHeaderExtensionUri::AbsCaptureTime), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: RtpHeaderExtensionUri) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for RtpHeaderExtensionUri { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for RtpHeaderExtensionUri { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for RtpHeaderExtensionUri { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> RtpHeaderExtensionUri { - *self - } - } - - impl ::planus::WriteAsDefault - for RtpHeaderExtensionUri - { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &RtpHeaderExtensionUri, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for RtpHeaderExtensionUri { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for RtpHeaderExtensionUri { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for RtpHeaderExtensionUri { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "RtpHeaderExtensionUri", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for RtpHeaderExtensionUri { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `RtpHeaderExtensionParameters` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtpHeaderExtensionParameters` in the file `../worker/fbs/rtpParameters.fbs:78` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct RtpHeaderExtensionParameters { - /// The field `uri` in the table `RtpHeaderExtensionParameters` - pub uri: self::RtpHeaderExtensionUri, - /// The field `id` in the table `RtpHeaderExtensionParameters` - pub id: u8, - /// The field `encrypt` in the table `RtpHeaderExtensionParameters` - pub encrypt: bool, - /// The field `parameters` in the table `RtpHeaderExtensionParameters` - pub parameters: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RtpHeaderExtensionParameters { - fn default() -> Self { - Self { - uri: self::RtpHeaderExtensionUri::Mid, - id: 0, - encrypt: false, - parameters: ::core::default::Default::default(), - } - } - } - - impl RtpHeaderExtensionParameters { - /// Creates a [RtpHeaderExtensionParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpHeaderExtensionParametersBuilder<()> { - RtpHeaderExtensionParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_uri: impl ::planus::WriteAsDefault< - self::RtpHeaderExtensionUri, - self::RtpHeaderExtensionUri, - >, - field_id: impl ::planus::WriteAsDefault, - field_encrypt: impl ::planus::WriteAsDefault, - field_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_uri = - field_uri.prepare(builder, &self::RtpHeaderExtensionUri::Mid); - let prepared_id = field_id.prepare(builder, &0); - let prepared_encrypt = field_encrypt.prepare(builder, &false); - let prepared_parameters = field_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_parameters.is_some() { - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>( - 3, - ); - } - if prepared_uri.is_some() { - table_writer.write_entry::(0); - } - if prepared_id.is_some() { - table_writer.write_entry::(1); - } - if prepared_encrypt.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_parameters) = - prepared_parameters - { - object_writer.write::<_, _, 4>(&prepared_parameters); - } - if let ::core::option::Option::Some(prepared_uri) = prepared_uri { - object_writer.write::<_, _, 1>(&prepared_uri); - } - if let ::core::option::Option::Some(prepared_id) = prepared_id { - object_writer.write::<_, _, 1>(&prepared_id); - } - if let ::core::option::Option::Some(prepared_encrypt) = prepared_encrypt - { - object_writer.write::<_, _, 1>(&prepared_encrypt); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for RtpHeaderExtensionParameters - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for RtpHeaderExtensionParameters - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpHeaderExtensionParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpHeaderExtensionParameters::create( - builder, - self.uri, - self.id, - self.encrypt, - &self.parameters, - ) - } - } - - /// Builder for serializing an instance of the [RtpHeaderExtensionParameters] type. - /// - /// Can be created using the [RtpHeaderExtensionParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpHeaderExtensionParametersBuilder(State); - - impl RtpHeaderExtensionParametersBuilder<()> { - /// Setter for the [`uri` field](RtpHeaderExtensionParameters#structfield.uri). - #[inline] - #[allow(clippy::type_complexity)] - pub fn uri(self, value: T0) -> RtpHeaderExtensionParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault< - self::RtpHeaderExtensionUri, - self::RtpHeaderExtensionUri, - >, - { - RtpHeaderExtensionParametersBuilder((value,)) - } - - /// Sets the [`uri` field](RtpHeaderExtensionParameters#structfield.uri) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn uri_as_default( - self, - ) -> RtpHeaderExtensionParametersBuilder<(::planus::DefaultValue,)> - { - self.uri(::planus::DefaultValue) - } - } - - impl RtpHeaderExtensionParametersBuilder<(T0,)> { - /// Setter for the [`id` field](RtpHeaderExtensionParameters#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T1) -> RtpHeaderExtensionParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RtpHeaderExtensionParametersBuilder((v0, value)) - } - - /// Sets the [`id` field](RtpHeaderExtensionParameters#structfield.id) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn id_as_default( - self, - ) -> RtpHeaderExtensionParametersBuilder<(T0, ::planus::DefaultValue)> - { - self.id(::planus::DefaultValue) - } - } - - impl RtpHeaderExtensionParametersBuilder<(T0, T1)> { - /// Setter for the [`encrypt` field](RtpHeaderExtensionParameters#structfield.encrypt). - #[inline] - #[allow(clippy::type_complexity)] - pub fn encrypt( - self, - value: T2, - ) -> RtpHeaderExtensionParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - RtpHeaderExtensionParametersBuilder((v0, v1, value)) - } - - /// Sets the [`encrypt` field](RtpHeaderExtensionParameters#structfield.encrypt) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn encrypt_as_default( - self, - ) -> RtpHeaderExtensionParametersBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.encrypt(::planus::DefaultValue) - } - } - - impl RtpHeaderExtensionParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`parameters` field](RtpHeaderExtensionParameters#structfield.parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn parameters( - self, - value: T3, - ) -> RtpHeaderExtensionParametersBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2) = self.0; - RtpHeaderExtensionParametersBuilder((v0, v1, v2, value)) - } - - /// Sets the [`parameters` field](RtpHeaderExtensionParameters#structfield.parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn parameters_as_null( - self, - ) -> RtpHeaderExtensionParametersBuilder<(T0, T1, T2, ())> { - self.parameters(()) - } - } - - impl RtpHeaderExtensionParametersBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpHeaderExtensionParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - self::RtpHeaderExtensionUri, - self::RtpHeaderExtensionUri, - >, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for RtpHeaderExtensionParametersBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - self::RtpHeaderExtensionUri, - self::RtpHeaderExtensionUri, - >, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for RtpHeaderExtensionParametersBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault< - self::RtpHeaderExtensionUri, - self::RtpHeaderExtensionUri, - >, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset - for RtpHeaderExtensionParametersBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - RtpHeaderExtensionParameters::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [RtpHeaderExtensionParameters]. - #[derive(Copy, Clone)] - pub struct RtpHeaderExtensionParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpHeaderExtensionParametersRef<'a> { - /// Getter for the [`uri` field](RtpHeaderExtensionParameters#structfield.uri). - #[inline] - pub fn uri(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "RtpHeaderExtensionParameters", "uri")? - .unwrap_or(self::RtpHeaderExtensionUri::Mid), - ) - } - - /// Getter for the [`id` field](RtpHeaderExtensionParameters#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "RtpHeaderExtensionParameters", "id")? - .unwrap_or(0), - ) - } - - /// Getter for the [`encrypt` field](RtpHeaderExtensionParameters#structfield.encrypt). - #[inline] - pub fn encrypt(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "RtpHeaderExtensionParameters", "encrypt")? - .unwrap_or(false), - ) - } - - /// Getter for the [`parameters` field](RtpHeaderExtensionParameters#structfield.parameters). - #[inline] - pub fn parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0 - .access(3, "RtpHeaderExtensionParameters", "parameters") - } - } - - impl<'a> ::core::fmt::Debug for RtpHeaderExtensionParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpHeaderExtensionParametersRef"); - f.field("uri", &self.uri()); - f.field("id", &self.id()); - f.field("encrypt", &self.encrypt()); - if let ::core::option::Option::Some(field_parameters) = - self.parameters().transpose() - { - f.field("parameters", &field_parameters); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for RtpHeaderExtensionParameters - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpHeaderExtensionParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - uri: ::core::convert::TryInto::try_into(value.uri()?)?, - id: ::core::convert::TryInto::try_into(value.id()?)?, - encrypt: ::core::convert::TryInto::try_into(value.encrypt()?)?, - parameters: if let ::core::option::Option::Some(parameters) = - value.parameters()? - { - ::core::option::Option::Some(parameters.to_vec_result()?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpHeaderExtensionParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpHeaderExtensionParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpHeaderExtensionParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for RtpHeaderExtensionParameters - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpHeaderExtensionParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[RtpHeaderExtensionParametersRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `Rtx` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `Rtx` in the file `../worker/fbs/rtpParameters.fbs:85` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Rtx { - /// The field `ssrc` in the table `Rtx` - pub ssrc: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Rtx { - fn default() -> Self { - Self { ssrc: 0 } - } - } - - impl Rtx { - /// Creates a [RtxBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtxBuilder<()> { - RtxBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Rtx { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Rtx { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Rtx { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Rtx::create(builder, self.ssrc) - } - } - - /// Builder for serializing an instance of the [Rtx] type. - /// - /// Can be created using the [Rtx::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtxBuilder(State); - - impl RtxBuilder<()> { - /// Setter for the [`ssrc` field](Rtx#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> RtxBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - RtxBuilder((value,)) - } - - /// Sets the [`ssrc` field](Rtx#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> RtxBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl RtxBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Rtx]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> ::planus::WriteAs<::planus::Offset> - for RtxBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> for RtxBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset for RtxBuilder<(T0,)> { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Rtx::create(builder, v0) - } - } - - /// Reference to a deserialized [Rtx]. - #[derive(Copy, Clone)] - pub struct RtxRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtxRef<'a> { - /// Getter for the [`ssrc` field](Rtx#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Rtx", "ssrc")?.unwrap_or(0)) - } - } - - impl<'a> ::core::fmt::Debug for RtxRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtxRef"); - f.field("ssrc", &self.ssrc()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Rtx { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtxRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtxRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtxRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location("[RtxRef]", "get", buffer.offset_from_start) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Rtx { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtxRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtxRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpEncodingParameters` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtpEncodingParameters` in the file `../worker/fbs/rtpParameters.fbs:89` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtpEncodingParameters { - /// The field `ssrc` in the table `RtpEncodingParameters` - pub ssrc: ::core::option::Option, - /// The field `rid` in the table `RtpEncodingParameters` - pub rid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `codec_payload_type` in the table `RtpEncodingParameters` - pub codec_payload_type: ::core::option::Option, - /// The field `rtx` in the table `RtpEncodingParameters` - pub rtx: ::core::option::Option<::planus::alloc::boxed::Box>, - /// The field `dtx` in the table `RtpEncodingParameters` - pub dtx: bool, - /// The field `scalability_mode` in the table `RtpEncodingParameters` - pub scalability_mode: ::core::option::Option<::planus::alloc::string::String>, - /// The field `max_bitrate` in the table `RtpEncodingParameters` - pub max_bitrate: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RtpEncodingParameters { - fn default() -> Self { - Self { - ssrc: ::core::default::Default::default(), - rid: ::core::default::Default::default(), - codec_payload_type: ::core::default::Default::default(), - rtx: ::core::default::Default::default(), - dtx: false, - scalability_mode: ::core::default::Default::default(), - max_bitrate: ::core::default::Default::default(), - } - } - } - - impl RtpEncodingParameters { - /// Creates a [RtpEncodingParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpEncodingParametersBuilder<()> { - RtpEncodingParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsOptional, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_codec_payload_type: impl ::planus::WriteAsOptional, - field_rtx: impl ::planus::WriteAsOptional<::planus::Offset>, - field_dtx: impl ::planus::WriteAsDefault, - field_scalability_mode: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_max_bitrate: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder); - let prepared_rid = field_rid.prepare(builder); - let prepared_codec_payload_type = field_codec_payload_type.prepare(builder); - let prepared_rtx = field_rtx.prepare(builder); - let prepared_dtx = field_dtx.prepare(builder, &false); - let prepared_scalability_mode = field_scalability_mode.prepare(builder); - let prepared_max_bitrate = field_max_bitrate.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<18> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - if prepared_rid.is_some() { - table_writer.write_entry::<::planus::Offset>(1); - } - if prepared_rtx.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_scalability_mode.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - if prepared_max_bitrate.is_some() { - table_writer.write_entry::(6); - } - if prepared_codec_payload_type.is_some() { - table_writer.write_entry::(2); - } - if prepared_dtx.is_some() { - table_writer.write_entry::(4); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 4>(&prepared_rid); - } - if let ::core::option::Option::Some(prepared_rtx) = prepared_rtx { - object_writer.write::<_, _, 4>(&prepared_rtx); - } - if let ::core::option::Option::Some(prepared_scalability_mode) = - prepared_scalability_mode - { - object_writer.write::<_, _, 4>(&prepared_scalability_mode); - } - if let ::core::option::Option::Some(prepared_max_bitrate) = - prepared_max_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_bitrate); - } - if let ::core::option::Option::Some(prepared_codec_payload_type) = - prepared_codec_payload_type - { - object_writer.write::<_, _, 1>(&prepared_codec_payload_type); - } - if let ::core::option::Option::Some(prepared_dtx) = prepared_dtx { - object_writer.write::<_, _, 1>(&prepared_dtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpEncodingParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpEncodingParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpEncodingParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpEncodingParameters::create( - builder, - self.ssrc, - &self.rid, - self.codec_payload_type, - &self.rtx, - self.dtx, - &self.scalability_mode, - self.max_bitrate, - ) - } - } - - /// Builder for serializing an instance of the [RtpEncodingParameters] type. - /// - /// Can be created using the [RtpEncodingParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpEncodingParametersBuilder(State); - - impl RtpEncodingParametersBuilder<()> { - /// Setter for the [`ssrc` field](RtpEncodingParameters#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> RtpEncodingParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional, - { - RtpEncodingParametersBuilder((value,)) - } - - /// Sets the [`ssrc` field](RtpEncodingParameters#structfield.ssrc) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_null(self) -> RtpEncodingParametersBuilder<((),)> { - self.ssrc(()) - } - } - - impl RtpEncodingParametersBuilder<(T0,)> { - /// Setter for the [`rid` field](RtpEncodingParameters#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid(self, value: T1) -> RtpEncodingParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0,) = self.0; - RtpEncodingParametersBuilder((v0, value)) - } - - /// Sets the [`rid` field](RtpEncodingParameters#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> RtpEncodingParametersBuilder<(T0, ())> { - self.rid(()) - } - } - - impl RtpEncodingParametersBuilder<(T0, T1)> { - /// Setter for the [`codec_payload_type` field](RtpEncodingParameters#structfield.codec_payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn codec_payload_type( - self, - value: T2, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - RtpEncodingParametersBuilder((v0, v1, value)) - } - - /// Sets the [`codec_payload_type` field](RtpEncodingParameters#structfield.codec_payload_type) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn codec_payload_type_as_null( - self, - ) -> RtpEncodingParametersBuilder<(T0, T1, ())> { - self.codec_payload_type(()) - } - } - - impl RtpEncodingParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`rtx` field](RtpEncodingParameters#structfield.rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx(self, value: T3) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - RtpEncodingParametersBuilder((v0, v1, v2, value)) - } - - /// Sets the [`rtx` field](RtpEncodingParameters#structfield.rtx) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_as_null(self) -> RtpEncodingParametersBuilder<(T0, T1, T2, ())> { - self.rtx(()) - } - } - - impl RtpEncodingParametersBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`dtx` field](RtpEncodingParameters#structfield.dtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtx( - self, - value: T4, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - RtpEncodingParametersBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`dtx` field](RtpEncodingParameters#structfield.dtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtx_as_default( - self, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.dtx(::planus::DefaultValue) - } - } - - impl RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`scalability_mode` field](RtpEncodingParameters#structfield.scalability_mode). - #[inline] - #[allow(clippy::type_complexity)] - pub fn scalability_mode( - self, - value: T5, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4) = self.0; - RtpEncodingParametersBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`scalability_mode` field](RtpEncodingParameters#structfield.scalability_mode) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn scalability_mode_as_null( - self, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, ())> { - self.scalability_mode(()) - } - } - - impl RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`max_bitrate` field](RtpEncodingParameters#structfield.max_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_bitrate( - self, - value: T6, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - RtpEncodingParametersBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`max_bitrate` field](RtpEncodingParameters#structfield.max_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_bitrate_as_null( - self, - ) -> RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5, ())> { - self.max_bitrate(()) - } - } - - impl RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpEncodingParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for RtpEncodingParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6) = &self.0; - RtpEncodingParameters::create(builder, v0, v1, v2, v3, v4, v5, v6) - } - } - - /// Reference to a deserialized [RtpEncodingParameters]. - #[derive(Copy, Clone)] - pub struct RtpEncodingParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpEncodingParametersRef<'a> { - /// Getter for the [`ssrc` field](RtpEncodingParameters#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(0, "RtpEncodingParameters", "ssrc") - } - - /// Getter for the [`rid` field](RtpEncodingParameters#structfield.rid). - #[inline] - pub fn rid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(1, "RtpEncodingParameters", "rid") - } - - /// Getter for the [`codec_payload_type` field](RtpEncodingParameters#structfield.codec_payload_type). - #[inline] - pub fn codec_payload_type(&self) -> ::planus::Result<::core::option::Option> { - self.0 - .access(2, "RtpEncodingParameters", "codec_payload_type") - } - - /// Getter for the [`rtx` field](RtpEncodingParameters#structfield.rtx). - #[inline] - pub fn rtx(&self) -> ::planus::Result<::core::option::Option>> { - self.0.access(3, "RtpEncodingParameters", "rtx") - } - - /// Getter for the [`dtx` field](RtpEncodingParameters#structfield.dtx). - #[inline] - pub fn dtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "RtpEncodingParameters", "dtx")? - .unwrap_or(false), - ) - } - - /// Getter for the [`scalability_mode` field](RtpEncodingParameters#structfield.scalability_mode). - #[inline] - pub fn scalability_mode( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0 - .access(5, "RtpEncodingParameters", "scalability_mode") - } - - /// Getter for the [`max_bitrate` field](RtpEncodingParameters#structfield.max_bitrate). - #[inline] - pub fn max_bitrate(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(6, "RtpEncodingParameters", "max_bitrate") - } - } - - impl<'a> ::core::fmt::Debug for RtpEncodingParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpEncodingParametersRef"); - if let ::core::option::Option::Some(field_ssrc) = self.ssrc().transpose() { - f.field("ssrc", &field_ssrc); - } - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - if let ::core::option::Option::Some(field_codec_payload_type) = - self.codec_payload_type().transpose() - { - f.field("codec_payload_type", &field_codec_payload_type); - } - if let ::core::option::Option::Some(field_rtx) = self.rtx().transpose() { - f.field("rtx", &field_rtx); - } - f.field("dtx", &self.dtx()); - if let ::core::option::Option::Some(field_scalability_mode) = - self.scalability_mode().transpose() - { - f.field("scalability_mode", &field_scalability_mode); - } - if let ::core::option::Option::Some(field_max_bitrate) = - self.max_bitrate().transpose() - { - f.field("max_bitrate", &field_max_bitrate); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpEncodingParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpEncodingParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: if let ::core::option::Option::Some(ssrc) = value.ssrc()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(ssrc)?) - } else { - ::core::option::Option::None - }, - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - codec_payload_type: if let ::core::option::Option::Some( - codec_payload_type, - ) = value.codec_payload_type()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - codec_payload_type, - )?) - } else { - ::core::option::Option::None - }, - rtx: if let ::core::option::Option::Some(rtx) = value.rtx()? { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtx)?, - )) - } else { - ::core::option::Option::None - }, - dtx: ::core::convert::TryInto::try_into(value.dtx()?)?, - scalability_mode: if let ::core::option::Option::Some(scalability_mode) = - value.scalability_mode()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - scalability_mode, - )?) - } else { - ::core::option::Option::None - }, - max_bitrate: if let ::core::option::Option::Some(max_bitrate) = - value.max_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - max_bitrate, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpEncodingParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpEncodingParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpEncodingParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpEncodingParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpEncodingParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[RtpEncodingParametersRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `RtcpParameters` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtcpParameters` in the file `../worker/fbs/rtpParameters.fbs:99` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtcpParameters { - /// The field `cname` in the table `RtcpParameters` - pub cname: ::core::option::Option<::planus::alloc::string::String>, - /// The field `reduced_size` in the table `RtcpParameters` - pub reduced_size: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RtcpParameters { - fn default() -> Self { - Self { - cname: ::core::default::Default::default(), - reduced_size: true, - } - } - } - - impl RtcpParameters { - /// Creates a [RtcpParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtcpParametersBuilder<()> { - RtcpParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_cname: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_reduced_size: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_cname = field_cname.prepare(builder); - let prepared_reduced_size = field_reduced_size.prepare(builder, &true); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_cname.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } - if prepared_reduced_size.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_cname) = prepared_cname { - object_writer.write::<_, _, 4>(&prepared_cname); - } - if let ::core::option::Option::Some(prepared_reduced_size) = - prepared_reduced_size - { - object_writer.write::<_, _, 1>(&prepared_reduced_size); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtcpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtcpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtcpParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtcpParameters::create(builder, &self.cname, self.reduced_size) - } - } - - /// Builder for serializing an instance of the [RtcpParameters] type. - /// - /// Can be created using the [RtcpParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtcpParametersBuilder(State); - - impl RtcpParametersBuilder<()> { - /// Setter for the [`cname` field](RtcpParameters#structfield.cname). - #[inline] - #[allow(clippy::type_complexity)] - pub fn cname(self, value: T0) -> RtcpParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - RtcpParametersBuilder((value,)) - } - - /// Sets the [`cname` field](RtcpParameters#structfield.cname) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn cname_as_null(self) -> RtcpParametersBuilder<((),)> { - self.cname(()) - } - } - - impl RtcpParametersBuilder<(T0,)> { - /// Setter for the [`reduced_size` field](RtcpParameters#structfield.reduced_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn reduced_size(self, value: T1) -> RtcpParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RtcpParametersBuilder((v0, value)) - } - - /// Sets the [`reduced_size` field](RtcpParameters#structfield.reduced_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn reduced_size_as_default( - self, - ) -> RtcpParametersBuilder<(T0, ::planus::DefaultValue)> { - self.reduced_size(::planus::DefaultValue) - } - } - - impl RtcpParametersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtcpParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for RtcpParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for RtcpParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for RtcpParametersBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - RtcpParameters::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [RtcpParameters]. - #[derive(Copy, Clone)] - pub struct RtcpParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtcpParametersRef<'a> { - /// Getter for the [`cname` field](RtcpParameters#structfield.cname). - #[inline] - pub fn cname( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "RtcpParameters", "cname") - } - - /// Getter for the [`reduced_size` field](RtcpParameters#structfield.reduced_size). - #[inline] - pub fn reduced_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "RtcpParameters", "reduced_size")? - .unwrap_or(true), - ) - } - } - - impl<'a> ::core::fmt::Debug for RtcpParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtcpParametersRef"); - if let ::core::option::Option::Some(field_cname) = self.cname().transpose() { - f.field("cname", &field_cname); - } - f.field("reduced_size", &self.reduced_size()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtcpParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtcpParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - cname: if let ::core::option::Option::Some(cname) = value.cname()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(cname)?) - } else { - ::core::option::Option::None - }, - reduced_size: ::core::convert::TryInto::try_into(value.reduced_size()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtcpParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtcpParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtcpParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtcpParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtcpParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtcpParametersRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpParameters` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtpParameters` in the file `../worker/fbs/rtpParameters.fbs:104` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct RtpParameters { - /// The field `mid` in the table `RtpParameters` - pub mid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `codecs` in the table `RtpParameters` - pub codecs: ::planus::alloc::vec::Vec, - /// The field `header_extensions` in the table `RtpParameters` - pub header_extensions: - ::planus::alloc::vec::Vec, - /// The field `encodings` in the table `RtpParameters` - pub encodings: ::planus::alloc::vec::Vec, - /// The field `rtcp` in the table `RtpParameters` - pub rtcp: ::planus::alloc::boxed::Box, - } - - impl RtpParameters { - /// Creates a [RtpParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpParametersBuilder<()> { - RtpParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_mid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_codecs: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_header_extensions: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_encodings: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_rtcp: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_mid = field_mid.prepare(builder); - let prepared_codecs = field_codecs.prepare(builder); - let prepared_header_extensions = field_header_extensions.prepare(builder); - let prepared_encodings = field_encodings.prepare(builder); - let prepared_rtcp = field_rtcp.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - if prepared_mid.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(2); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(3); - table_writer.write_entry::<::planus::Offset>(4); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_mid) = prepared_mid { - object_writer.write::<_, _, 4>(&prepared_mid); - } - object_writer.write::<_, _, 4>(&prepared_codecs); - object_writer.write::<_, _, 4>(&prepared_header_extensions); - object_writer.write::<_, _, 4>(&prepared_encodings); - object_writer.write::<_, _, 4>(&prepared_rtcp); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpParameters::create( - builder, - &self.mid, - &self.codecs, - &self.header_extensions, - &self.encodings, - &self.rtcp, - ) - } - } - - /// Builder for serializing an instance of the [RtpParameters] type. - /// - /// Can be created using the [RtpParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpParametersBuilder(State); - - impl RtpParametersBuilder<()> { - /// Setter for the [`mid` field](RtpParameters#structfield.mid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid(self, value: T0) -> RtpParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - RtpParametersBuilder((value,)) - } - - /// Sets the [`mid` field](RtpParameters#structfield.mid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid_as_null(self) -> RtpParametersBuilder<((),)> { - self.mid(()) - } - } - - impl RtpParametersBuilder<(T0,)> { - /// Setter for the [`codecs` field](RtpParameters#structfield.codecs). - #[inline] - #[allow(clippy::type_complexity)] - pub fn codecs(self, value: T1) -> RtpParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0,) = self.0; - RtpParametersBuilder((v0, value)) - } - } - - impl RtpParametersBuilder<(T0, T1)> { - /// Setter for the [`header_extensions` field](RtpParameters#structfield.header_extensions). - #[inline] - #[allow(clippy::type_complexity)] - pub fn header_extensions(self, value: T2) -> RtpParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1) = self.0; - RtpParametersBuilder((v0, v1, value)) - } - } - - impl RtpParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`encodings` field](RtpParameters#structfield.encodings). - #[inline] - #[allow(clippy::type_complexity)] - pub fn encodings(self, value: T3) -> RtpParametersBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2) = self.0; - RtpParametersBuilder((v0, v1, v2, value)) - } - } - - impl RtpParametersBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtcp` field](RtpParameters#structfield.rtcp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp(self, value: T4) -> RtpParametersBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - RtpParametersBuilder((v0, v1, v2, v3, value)) - } - } - - impl RtpParametersBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T4: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for RtpParametersBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T4: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpParametersBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T4: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset - for RtpParametersBuilder<(T0, T1, T2, T3, T4)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4) = &self.0; - RtpParameters::create(builder, v0, v1, v2, v3, v4) - } - } - - /// Reference to a deserialized [RtpParameters]. - #[derive(Copy, Clone)] - pub struct RtpParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpParametersRef<'a> { - /// Getter for the [`mid` field](RtpParameters#structfield.mid). - #[inline] - pub fn mid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "RtpParameters", "mid") - } - - /// Getter for the [`codecs` field](RtpParameters#structfield.codecs). - #[inline] - pub fn codecs( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(1, "RtpParameters", "codecs") - } - - /// Getter for the [`header_extensions` field](RtpParameters#structfield.header_extensions). - #[inline] - pub fn header_extensions( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::planus::Result>, - >, - > { - self.0 - .access_required(2, "RtpParameters", "header_extensions") - } - - /// Getter for the [`encodings` field](RtpParameters#structfield.encodings). - #[inline] - pub fn encodings( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(3, "RtpParameters", "encodings") - } - - /// Getter for the [`rtcp` field](RtpParameters#structfield.rtcp). - #[inline] - pub fn rtcp(&self) -> ::planus::Result> { - self.0.access_required(4, "RtpParameters", "rtcp") - } - } - - impl<'a> ::core::fmt::Debug for RtpParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpParametersRef"); - if let ::core::option::Option::Some(field_mid) = self.mid().transpose() { - f.field("mid", &field_mid); - } - f.field("codecs", &self.codecs()); - f.field("header_extensions", &self.header_extensions()); - f.field("encodings", &self.encodings()); - f.field("rtcp", &self.rtcp()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - mid: if let ::core::option::Option::Some(mid) = value.mid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(mid)?) - } else { - ::core::option::Option::None - }, - codecs: value.codecs()?.to_vec_result()?, - header_extensions: value.header_extensions()?.to_vec_result()?, - encodings: value.encodings()?.to_vec_result()?, - rtcp: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.rtcp()?, - )?), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpParametersRef]", "read_as_root", 0) - }) - } - } - - /// The table `CodecMapping` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `CodecMapping` in the file `../worker/fbs/rtpParameters.fbs:112` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CodecMapping { - /// The field `payload_type` in the table `CodecMapping` - pub payload_type: u8, - /// The field `mapped_payload_type` in the table `CodecMapping` - pub mapped_payload_type: u8, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for CodecMapping { - fn default() -> Self { - Self { - payload_type: 0, - mapped_payload_type: 0, - } - } - } - - impl CodecMapping { - /// Creates a [CodecMappingBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CodecMappingBuilder<()> { - CodecMappingBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_payload_type: impl ::planus::WriteAsDefault, - field_mapped_payload_type: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_payload_type = field_payload_type.prepare(builder, &0); - let prepared_mapped_payload_type = - field_mapped_payload_type.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_payload_type.is_some() { - table_writer.write_entry::(0); - } - if prepared_mapped_payload_type.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - object_writer.write::<_, _, 1>(&prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_mapped_payload_type) = - prepared_mapped_payload_type - { - object_writer.write::<_, _, 1>(&prepared_mapped_payload_type); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CodecMapping { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for CodecMapping { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CodecMapping { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CodecMapping::create(builder, self.payload_type, self.mapped_payload_type) - } - } - - /// Builder for serializing an instance of the [CodecMapping] type. - /// - /// Can be created using the [CodecMapping::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CodecMappingBuilder(State); - - impl CodecMappingBuilder<()> { - /// Setter for the [`payload_type` field](CodecMapping#structfield.payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type(self, value: T0) -> CodecMappingBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - CodecMappingBuilder((value,)) - } - - /// Sets the [`payload_type` field](CodecMapping#structfield.payload_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type_as_default( - self, - ) -> CodecMappingBuilder<(::planus::DefaultValue,)> { - self.payload_type(::planus::DefaultValue) - } - } - - impl CodecMappingBuilder<(T0,)> { - /// Setter for the [`mapped_payload_type` field](CodecMapping#structfield.mapped_payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mapped_payload_type(self, value: T1) -> CodecMappingBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - CodecMappingBuilder((v0, value)) - } - - /// Sets the [`mapped_payload_type` field](CodecMapping#structfield.mapped_payload_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mapped_payload_type_as_default( - self, - ) -> CodecMappingBuilder<(T0, ::planus::DefaultValue)> { - self.mapped_payload_type(::planus::DefaultValue) - } - } - - impl CodecMappingBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CodecMapping]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl, T1: ::planus::WriteAsDefault> - ::planus::WriteAs<::planus::Offset> - for CodecMappingBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl, T1: ::planus::WriteAsDefault> - ::planus::WriteAsOptional<::planus::Offset> - for CodecMappingBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl, T1: ::planus::WriteAsDefault> - ::planus::WriteAsOffset for CodecMappingBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CodecMapping::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CodecMapping]. - #[derive(Copy, Clone)] - pub struct CodecMappingRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CodecMappingRef<'a> { - /// Getter for the [`payload_type` field](CodecMapping#structfield.payload_type). - #[inline] - pub fn payload_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "CodecMapping", "payload_type")? - .unwrap_or(0), - ) - } - - /// Getter for the [`mapped_payload_type` field](CodecMapping#structfield.mapped_payload_type). - #[inline] - pub fn mapped_payload_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "CodecMapping", "mapped_payload_type")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for CodecMappingRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CodecMappingRef"); - f.field("payload_type", &self.payload_type()); - f.field("mapped_payload_type", &self.mapped_payload_type()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CodecMapping { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CodecMappingRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - payload_type: ::core::convert::TryInto::try_into(value.payload_type()?)?, - mapped_payload_type: ::core::convert::TryInto::try_into( - value.mapped_payload_type()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CodecMappingRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CodecMappingRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CodecMappingRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CodecMapping { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CodecMappingRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[CodecMappingRef]", "read_as_root", 0) - }) - } - } - - /// The table `EncodingMapping` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `EncodingMapping` in the file `../worker/fbs/rtpParameters.fbs:117` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct EncodingMapping { - /// The field `rid` in the table `EncodingMapping` - pub rid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `ssrc` in the table `EncodingMapping` - pub ssrc: ::core::option::Option, - /// The field `scalability_mode` in the table `EncodingMapping` - pub scalability_mode: ::core::option::Option<::planus::alloc::string::String>, - /// The field `mapped_ssrc` in the table `EncodingMapping` - pub mapped_ssrc: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for EncodingMapping { - fn default() -> Self { - Self { - rid: ::core::default::Default::default(), - ssrc: ::core::default::Default::default(), - scalability_mode: ::core::default::Default::default(), - mapped_ssrc: 0, - } - } - } - - impl EncodingMapping { - /// Creates a [EncodingMappingBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> EncodingMappingBuilder<()> { - EncodingMappingBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_ssrc: impl ::planus::WriteAsOptional, - field_scalability_mode: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_mapped_ssrc: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_rid = field_rid.prepare(builder); - let prepared_ssrc = field_ssrc.prepare(builder); - let prepared_scalability_mode = field_scalability_mode.prepare(builder); - let prepared_mapped_ssrc = field_mapped_ssrc.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_rid.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } - if prepared_ssrc.is_some() { - table_writer.write_entry::(1); - } - if prepared_scalability_mode.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_mapped_ssrc.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 4>(&prepared_rid); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_scalability_mode) = - prepared_scalability_mode - { - object_writer.write::<_, _, 4>(&prepared_scalability_mode); - } - if let ::core::option::Option::Some(prepared_mapped_ssrc) = - prepared_mapped_ssrc - { - object_writer.write::<_, _, 4>(&prepared_mapped_ssrc); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for EncodingMapping { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for EncodingMapping { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for EncodingMapping { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - EncodingMapping::create( - builder, - &self.rid, - self.ssrc, - &self.scalability_mode, - self.mapped_ssrc, - ) - } - } - - /// Builder for serializing an instance of the [EncodingMapping] type. - /// - /// Can be created using the [EncodingMapping::builder] method. - #[derive(Debug)] - #[must_use] - pub struct EncodingMappingBuilder(State); - - impl EncodingMappingBuilder<()> { - /// Setter for the [`rid` field](EncodingMapping#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid(self, value: T0) -> EncodingMappingBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - EncodingMappingBuilder((value,)) - } - - /// Sets the [`rid` field](EncodingMapping#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> EncodingMappingBuilder<((),)> { - self.rid(()) - } - } - - impl EncodingMappingBuilder<(T0,)> { - /// Setter for the [`ssrc` field](EncodingMapping#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T1) -> EncodingMappingBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - EncodingMappingBuilder((v0, value)) - } - - /// Sets the [`ssrc` field](EncodingMapping#structfield.ssrc) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_null(self) -> EncodingMappingBuilder<(T0, ())> { - self.ssrc(()) - } - } - - impl EncodingMappingBuilder<(T0, T1)> { - /// Setter for the [`scalability_mode` field](EncodingMapping#structfield.scalability_mode). - #[inline] - #[allow(clippy::type_complexity)] - pub fn scalability_mode(self, value: T2) -> EncodingMappingBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1) = self.0; - EncodingMappingBuilder((v0, v1, value)) - } - - /// Sets the [`scalability_mode` field](EncodingMapping#structfield.scalability_mode) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn scalability_mode_as_null(self) -> EncodingMappingBuilder<(T0, T1, ())> { - self.scalability_mode(()) - } - } - - impl EncodingMappingBuilder<(T0, T1, T2)> { - /// Setter for the [`mapped_ssrc` field](EncodingMapping#structfield.mapped_ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mapped_ssrc(self, value: T3) -> EncodingMappingBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - EncodingMappingBuilder((v0, v1, v2, value)) - } - - /// Sets the [`mapped_ssrc` field](EncodingMapping#structfield.mapped_ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mapped_ssrc_as_default( - self, - ) -> EncodingMappingBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.mapped_ssrc(::planus::DefaultValue) - } - } - - impl EncodingMappingBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [EncodingMapping]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for EncodingMappingBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for EncodingMappingBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for EncodingMappingBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - EncodingMapping::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [EncodingMapping]. - #[derive(Copy, Clone)] - pub struct EncodingMappingRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> EncodingMappingRef<'a> { - /// Getter for the [`rid` field](EncodingMapping#structfield.rid). - #[inline] - pub fn rid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "EncodingMapping", "rid") - } - - /// Getter for the [`ssrc` field](EncodingMapping#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "EncodingMapping", "ssrc") - } - - /// Getter for the [`scalability_mode` field](EncodingMapping#structfield.scalability_mode). - #[inline] - pub fn scalability_mode( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(2, "EncodingMapping", "scalability_mode") - } - - /// Getter for the [`mapped_ssrc` field](EncodingMapping#structfield.mapped_ssrc). - #[inline] - pub fn mapped_ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "EncodingMapping", "mapped_ssrc")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for EncodingMappingRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("EncodingMappingRef"); - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - if let ::core::option::Option::Some(field_ssrc) = self.ssrc().transpose() { - f.field("ssrc", &field_ssrc); - } - if let ::core::option::Option::Some(field_scalability_mode) = - self.scalability_mode().transpose() - { - f.field("scalability_mode", &field_scalability_mode); - } - f.field("mapped_ssrc", &self.mapped_ssrc()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for EncodingMapping { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: EncodingMappingRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - ssrc: if let ::core::option::Option::Some(ssrc) = value.ssrc()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(ssrc)?) - } else { - ::core::option::Option::None - }, - scalability_mode: if let ::core::option::Option::Some(scalability_mode) = - value.scalability_mode()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - scalability_mode, - )?) - } else { - ::core::option::Option::None - }, - mapped_ssrc: ::core::convert::TryInto::try_into(value.mapped_ssrc()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for EncodingMappingRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for EncodingMappingRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[EncodingMappingRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for EncodingMapping { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for EncodingMappingRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[EncodingMappingRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpMapping` in the namespace `FBS.RtpParameters` - /// - /// Generated from these locations: - /// * Table `RtpMapping` in the file `../worker/fbs/rtpParameters.fbs:124` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtpMapping { - /// The field `codecs` in the table `RtpMapping` - pub codecs: ::planus::alloc::vec::Vec, - /// The field `encodings` in the table `RtpMapping` - pub encodings: ::planus::alloc::vec::Vec, - } - - impl RtpMapping { - /// Creates a [RtpMappingBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpMappingBuilder<()> { - RtpMappingBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_codecs: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_encodings: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_codecs = field_codecs.prepare(builder); - let prepared_encodings = field_encodings.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(0); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>( - 1, - ); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_codecs); - object_writer.write::<_, _, 4>(&prepared_encodings); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpMapping { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpMapping { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpMapping { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - RtpMapping::create(builder, &self.codecs, &self.encodings) - } - } - - /// Builder for serializing an instance of the [RtpMapping] type. - /// - /// Can be created using the [RtpMapping::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpMappingBuilder(State); - - impl RtpMappingBuilder<()> { - /// Setter for the [`codecs` field](RtpMapping#structfield.codecs). - #[inline] - #[allow(clippy::type_complexity)] - pub fn codecs(self, value: T0) -> RtpMappingBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - RtpMappingBuilder((value,)) - } - } - - impl RtpMappingBuilder<(T0,)> { - /// Setter for the [`encodings` field](RtpMapping#structfield.encodings). - #[inline] - #[allow(clippy::type_complexity)] - pub fn encodings(self, value: T1) -> RtpMappingBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0,) = self.0; - RtpMappingBuilder((v0, value)) - } - } - - impl RtpMappingBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpMapping]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> for RtpMappingBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpMappingBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset for RtpMappingBuilder<(T0, T1)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - RtpMapping::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [RtpMapping]. - #[derive(Copy, Clone)] - pub struct RtpMappingRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpMappingRef<'a> { - /// Getter for the [`codecs` field](RtpMapping#structfield.codecs). - #[inline] - pub fn codecs( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "RtpMapping", "codecs") - } - - /// Getter for the [`encodings` field](RtpMapping#structfield.encodings). - #[inline] - pub fn encodings( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(1, "RtpMapping", "encodings") - } - } - - impl<'a> ::core::fmt::Debug for RtpMappingRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpMappingRef"); - f.field("codecs", &self.codecs()); - f.field("encodings", &self.encodings()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpMapping { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpMappingRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - codecs: value.codecs()?.to_vec_result()?, - encodings: value.encodings()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpMappingRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpMappingRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpMappingRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpMapping { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpMappingRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpMappingRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * File `../worker/fbs/rtpStream.fbs` - pub mod rtp_stream { - /// The table `Params` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `Params` in the file `../worker/fbs/rtpStream.fbs:6` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Params { - /// The field `encoding_idx` in the table `Params` - pub encoding_idx: u32, - /// The field `ssrc` in the table `Params` - pub ssrc: u32, - /// The field `payload_type` in the table `Params` - pub payload_type: u8, - /// The field `mime_type` in the table `Params` - pub mime_type: ::planus::alloc::string::String, - /// The field `clock_rate` in the table `Params` - pub clock_rate: u32, - /// The field `rid` in the table `Params` - pub rid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `cname` in the table `Params` - pub cname: ::planus::alloc::string::String, - /// The field `rtx_ssrc` in the table `Params` - pub rtx_ssrc: ::core::option::Option, - /// The field `rtx_payload_type` in the table `Params` - pub rtx_payload_type: ::core::option::Option, - /// The field `use_nack` in the table `Params` - pub use_nack: bool, - /// The field `use_pli` in the table `Params` - pub use_pli: bool, - /// The field `use_fir` in the table `Params` - pub use_fir: bool, - /// The field `use_in_band_fec` in the table `Params` - pub use_in_band_fec: bool, - /// The field `use_dtx` in the table `Params` - pub use_dtx: bool, - /// The field `spatial_layers` in the table `Params` - pub spatial_layers: u8, - /// The field `temporal_layers` in the table `Params` - pub temporal_layers: u8, - } - - impl Params { - /// Creates a [ParamsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ParamsBuilder<()> { - ParamsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_encoding_idx: impl ::planus::WriteAsDefault, - field_ssrc: impl ::planus::WriteAsDefault, - field_payload_type: impl ::planus::WriteAsDefault, - field_mime_type: impl ::planus::WriteAs<::planus::Offset>, - field_clock_rate: impl ::planus::WriteAsDefault, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_cname: impl ::planus::WriteAs<::planus::Offset>, - field_rtx_ssrc: impl ::planus::WriteAsOptional, - field_rtx_payload_type: impl ::planus::WriteAsOptional, - field_use_nack: impl ::planus::WriteAsDefault, - field_use_pli: impl ::planus::WriteAsDefault, - field_use_fir: impl ::planus::WriteAsDefault, - field_use_in_band_fec: impl ::planus::WriteAsDefault, - field_use_dtx: impl ::planus::WriteAsDefault, - field_spatial_layers: impl ::planus::WriteAsDefault, - field_temporal_layers: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_encoding_idx = field_encoding_idx.prepare(builder, &0); - let prepared_ssrc = field_ssrc.prepare(builder, &0); - let prepared_payload_type = field_payload_type.prepare(builder, &0); - let prepared_mime_type = field_mime_type.prepare(builder); - let prepared_clock_rate = field_clock_rate.prepare(builder, &0); - let prepared_rid = field_rid.prepare(builder); - let prepared_cname = field_cname.prepare(builder); - let prepared_rtx_ssrc = field_rtx_ssrc.prepare(builder); - let prepared_rtx_payload_type = field_rtx_payload_type.prepare(builder); - let prepared_use_nack = field_use_nack.prepare(builder, &false); - let prepared_use_pli = field_use_pli.prepare(builder, &false); - let prepared_use_fir = field_use_fir.prepare(builder, &false); - let prepared_use_in_band_fec = field_use_in_band_fec.prepare(builder, &false); - let prepared_use_dtx = field_use_dtx.prepare(builder, &false); - let prepared_spatial_layers = field_spatial_layers.prepare(builder, &0); - let prepared_temporal_layers = field_temporal_layers.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<36> = - ::core::default::Default::default(); - if prepared_encoding_idx.is_some() { - table_writer.write_entry::(0); - } - if prepared_ssrc.is_some() { - table_writer.write_entry::(1); - } - table_writer.write_entry::<::planus::Offset>(3); - if prepared_clock_rate.is_some() { - table_writer.write_entry::(4); - } - if prepared_rid.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - table_writer.write_entry::<::planus::Offset>(6); - if prepared_rtx_ssrc.is_some() { - table_writer.write_entry::(7); - } - if prepared_payload_type.is_some() { - table_writer.write_entry::(2); - } - if prepared_rtx_payload_type.is_some() { - table_writer.write_entry::(8); - } - if prepared_use_nack.is_some() { - table_writer.write_entry::(9); - } - if prepared_use_pli.is_some() { - table_writer.write_entry::(10); - } - if prepared_use_fir.is_some() { - table_writer.write_entry::(11); - } - if prepared_use_in_band_fec.is_some() { - table_writer.write_entry::(12); - } - if prepared_use_dtx.is_some() { - table_writer.write_entry::(13); - } - if prepared_spatial_layers.is_some() { - table_writer.write_entry::(14); - } - if prepared_temporal_layers.is_some() { - table_writer.write_entry::(15); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_encoding_idx) = - prepared_encoding_idx - { - object_writer.write::<_, _, 4>(&prepared_encoding_idx); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - object_writer.write::<_, _, 4>(&prepared_mime_type); - if let ::core::option::Option::Some(prepared_clock_rate) = - prepared_clock_rate - { - object_writer.write::<_, _, 4>(&prepared_clock_rate); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 4>(&prepared_rid); - } - object_writer.write::<_, _, 4>(&prepared_cname); - if let ::core::option::Option::Some(prepared_rtx_ssrc) = - prepared_rtx_ssrc - { - object_writer.write::<_, _, 4>(&prepared_rtx_ssrc); - } - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - object_writer.write::<_, _, 1>(&prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_rtx_payload_type) = - prepared_rtx_payload_type - { - object_writer.write::<_, _, 1>(&prepared_rtx_payload_type); - } - if let ::core::option::Option::Some(prepared_use_nack) = - prepared_use_nack - { - object_writer.write::<_, _, 1>(&prepared_use_nack); - } - if let ::core::option::Option::Some(prepared_use_pli) = prepared_use_pli - { - object_writer.write::<_, _, 1>(&prepared_use_pli); - } - if let ::core::option::Option::Some(prepared_use_fir) = prepared_use_fir - { - object_writer.write::<_, _, 1>(&prepared_use_fir); - } - if let ::core::option::Option::Some(prepared_use_in_band_fec) = - prepared_use_in_band_fec - { - object_writer.write::<_, _, 1>(&prepared_use_in_band_fec); - } - if let ::core::option::Option::Some(prepared_use_dtx) = prepared_use_dtx - { - object_writer.write::<_, _, 1>(&prepared_use_dtx); - } - if let ::core::option::Option::Some(prepared_spatial_layers) = - prepared_spatial_layers - { - object_writer.write::<_, _, 1>(&prepared_spatial_layers); - } - if let ::core::option::Option::Some(prepared_temporal_layers) = - prepared_temporal_layers - { - object_writer.write::<_, _, 1>(&prepared_temporal_layers); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Params { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Params { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Params { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Params::create( - builder, - self.encoding_idx, - self.ssrc, - self.payload_type, - &self.mime_type, - self.clock_rate, - &self.rid, - &self.cname, - self.rtx_ssrc, - self.rtx_payload_type, - self.use_nack, - self.use_pli, - self.use_fir, - self.use_in_band_fec, - self.use_dtx, - self.spatial_layers, - self.temporal_layers, - ) - } - } - - /// Builder for serializing an instance of the [Params] type. - /// - /// Can be created using the [Params::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ParamsBuilder(State); - - impl ParamsBuilder<()> { - /// Setter for the [`encoding_idx` field](Params#structfield.encoding_idx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn encoding_idx(self, value: T0) -> ParamsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ParamsBuilder((value,)) - } - - /// Sets the [`encoding_idx` field](Params#structfield.encoding_idx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn encoding_idx_as_default(self) -> ParamsBuilder<(::planus::DefaultValue,)> { - self.encoding_idx(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0,)> { - /// Setter for the [`ssrc` field](Params#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T1) -> ParamsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ParamsBuilder((v0, value)) - } - - /// Sets the [`ssrc` field](Params#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> ParamsBuilder<(T0, ::planus::DefaultValue)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0, T1)> { - /// Setter for the [`payload_type` field](Params#structfield.payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type(self, value: T2) -> ParamsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - ParamsBuilder((v0, v1, value)) - } - - /// Sets the [`payload_type` field](Params#structfield.payload_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type_as_default( - self, - ) -> ParamsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.payload_type(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0, T1, T2)> { - /// Setter for the [`mime_type` field](Params#structfield.mime_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mime_type(self, value: T3) -> ParamsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - ParamsBuilder((v0, v1, v2, value)) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`clock_rate` field](Params#structfield.clock_rate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn clock_rate(self, value: T4) -> ParamsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - ParamsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`clock_rate` field](Params#structfield.clock_rate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn clock_rate_as_default( - self, - ) -> ParamsBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.clock_rate(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`rid` field](Params#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid(self, value: T5) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`rid` field](Params#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> ParamsBuilder<(T0, T1, T2, T3, T4, ())> { - self.rid(()) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`cname` field](Params#structfield.cname). - #[inline] - #[allow(clippy::type_complexity)] - pub fn cname(self, value: T6) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, value)) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`rtx_ssrc` field](Params#structfield.rtx_ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_ssrc( - self, - value: T7, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`rtx_ssrc` field](Params#structfield.rtx_ssrc) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_ssrc_as_null(self) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, ())> { - self.rtx_ssrc(()) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`rtx_payload_type` field](Params#structfield.rtx_payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_payload_type( - self, - value: T8, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`rtx_payload_type` field](Params#structfield.rtx_payload_type) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_payload_type_as_null( - self, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ())> { - self.rtx_payload_type(()) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`use_nack` field](Params#structfield.use_nack). - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_nack( - self, - value: T9, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - - /// Sets the [`use_nack` field](Params#structfield.use_nack) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_nack_as_default( - self, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, ::planus::DefaultValue)> - { - self.use_nack(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - /// Setter for the [`use_pli` field](Params#structfield.use_pli). - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_pli( - self, - value: T10, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`use_pli` field](Params#structfield.use_pli) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_pli_as_default( - self, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - ::planus::DefaultValue, - )> { - self.use_pli(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Setter for the [`use_fir` field](Params#structfield.use_fir). - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_fir( - self, - value: T11, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - where - T11: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, value)) - } - - /// Sets the [`use_fir` field](Params#structfield.use_fir) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_fir_as_default( - self, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - ::planus::DefaultValue, - )> { - self.use_fir(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`use_in_band_fec` field](Params#structfield.use_in_band_fec). - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_in_band_fec( - self, - value: T12, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - where - T12: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, value)) - } - - /// Sets the [`use_in_band_fec` field](Params#structfield.use_in_band_fec) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_in_band_fec_as_default( - self, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - ::planus::DefaultValue, - )> { - self.use_in_band_fec(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - { - /// Setter for the [`use_dtx` field](Params#structfield.use_dtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_dtx( - self, - value: T13, - ) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - where - T13: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, value)) - } - - /// Sets the [`use_dtx` field](Params#structfield.use_dtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn use_dtx_as_default( - self, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - ::planus::DefaultValue, - )> { - self.use_dtx(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - /// Setter for the [`spatial_layers` field](Params#structfield.spatial_layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn spatial_layers( - self, - value: T14, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - where - T14: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) = self.0; - ParamsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, value, - )) - } - - /// Sets the [`spatial_layers` field](Params#structfield.spatial_layers) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn spatial_layers_as_default( - self, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - ::planus::DefaultValue, - )> { - self.spatial_layers(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - /// Setter for the [`temporal_layers` field](Params#structfield.temporal_layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn temporal_layers( - self, - value: T15, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - where - T15: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) = self.0; - ParamsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, value, - )) - } - - /// Sets the [`temporal_layers` field](Params#structfield.temporal_layers) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn temporal_layers_as_default( - self, - ) -> ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - ::planus::DefaultValue, - )> { - self.temporal_layers(::planus::DefaultValue) - } - } - - impl - ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Params]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAsOptional, - T8: ::planus::WriteAsOptional, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAsOptional, - T8: ::planus::WriteAsOptional, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAsOptional, - T8: ::planus::WriteAsOptional, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for ParamsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) = - &self.0; - Params::create( - builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, - v15, - ) - } - } - - /// Reference to a deserialized [Params]. - #[derive(Copy, Clone)] - pub struct ParamsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ParamsRef<'a> { - /// Getter for the [`encoding_idx` field](Params#structfield.encoding_idx). - #[inline] - pub fn encoding_idx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "Params", "encoding_idx")?.unwrap_or(0), - ) - } - - /// Getter for the [`ssrc` field](Params#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Params", "ssrc")?.unwrap_or(0)) - } - - /// Getter for the [`payload_type` field](Params#structfield.payload_type). - #[inline] - pub fn payload_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(2, "Params", "payload_type")?.unwrap_or(0), - ) - } - - /// Getter for the [`mime_type` field](Params#structfield.mime_type). - #[inline] - pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(3, "Params", "mime_type") - } - - /// Getter for the [`clock_rate` field](Params#structfield.clock_rate). - #[inline] - pub fn clock_rate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(4, "Params", "clock_rate")?.unwrap_or(0), - ) - } - - /// Getter for the [`rid` field](Params#structfield.rid). - #[inline] - pub fn rid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(5, "Params", "rid") - } - - /// Getter for the [`cname` field](Params#structfield.cname). - #[inline] - pub fn cname(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(6, "Params", "cname") - } - - /// Getter for the [`rtx_ssrc` field](Params#structfield.rtx_ssrc). - #[inline] - pub fn rtx_ssrc(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(7, "Params", "rtx_ssrc") - } - - /// Getter for the [`rtx_payload_type` field](Params#structfield.rtx_payload_type). - #[inline] - pub fn rtx_payload_type(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(8, "Params", "rtx_payload_type") - } - - /// Getter for the [`use_nack` field](Params#structfield.use_nack). - #[inline] - pub fn use_nack(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(9, "Params", "use_nack")?.unwrap_or(false), - ) - } - - /// Getter for the [`use_pli` field](Params#structfield.use_pli). - #[inline] - pub fn use_pli(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(10, "Params", "use_pli")?.unwrap_or(false), - ) - } - - /// Getter for the [`use_fir` field](Params#structfield.use_fir). - #[inline] - pub fn use_fir(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(11, "Params", "use_fir")?.unwrap_or(false), - ) - } - - /// Getter for the [`use_in_band_fec` field](Params#structfield.use_in_band_fec). - #[inline] - pub fn use_in_band_fec(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(12, "Params", "use_in_band_fec")? - .unwrap_or(false), - ) - } - - /// Getter for the [`use_dtx` field](Params#structfield.use_dtx). - #[inline] - pub fn use_dtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(13, "Params", "use_dtx")?.unwrap_or(false), - ) - } - - /// Getter for the [`spatial_layers` field](Params#structfield.spatial_layers). - #[inline] - pub fn spatial_layers(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(14, "Params", "spatial_layers")?.unwrap_or(0), - ) - } - - /// Getter for the [`temporal_layers` field](Params#structfield.temporal_layers). - #[inline] - pub fn temporal_layers(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(15, "Params", "temporal_layers")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for ParamsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ParamsRef"); - f.field("encoding_idx", &self.encoding_idx()); - f.field("ssrc", &self.ssrc()); - f.field("payload_type", &self.payload_type()); - f.field("mime_type", &self.mime_type()); - f.field("clock_rate", &self.clock_rate()); - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - f.field("cname", &self.cname()); - if let ::core::option::Option::Some(field_rtx_ssrc) = - self.rtx_ssrc().transpose() - { - f.field("rtx_ssrc", &field_rtx_ssrc); - } - if let ::core::option::Option::Some(field_rtx_payload_type) = - self.rtx_payload_type().transpose() - { - f.field("rtx_payload_type", &field_rtx_payload_type); - } - f.field("use_nack", &self.use_nack()); - f.field("use_pli", &self.use_pli()); - f.field("use_fir", &self.use_fir()); - f.field("use_in_band_fec", &self.use_in_band_fec()); - f.field("use_dtx", &self.use_dtx()); - f.field("spatial_layers", &self.spatial_layers()); - f.field("temporal_layers", &self.temporal_layers()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Params { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ParamsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - encoding_idx: ::core::convert::TryInto::try_into(value.encoding_idx()?)?, - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - payload_type: ::core::convert::TryInto::try_into(value.payload_type()?)?, - mime_type: ::core::convert::TryInto::try_into(value.mime_type()?)?, - clock_rate: ::core::convert::TryInto::try_into(value.clock_rate()?)?, - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - cname: ::core::convert::TryInto::try_into(value.cname()?)?, - rtx_ssrc: if let ::core::option::Option::Some(rtx_ssrc) = - value.rtx_ssrc()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - rtx_ssrc, - )?) - } else { - ::core::option::Option::None - }, - rtx_payload_type: if let ::core::option::Option::Some(rtx_payload_type) = - value.rtx_payload_type()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - rtx_payload_type, - )?) - } else { - ::core::option::Option::None - }, - use_nack: ::core::convert::TryInto::try_into(value.use_nack()?)?, - use_pli: ::core::convert::TryInto::try_into(value.use_pli()?)?, - use_fir: ::core::convert::TryInto::try_into(value.use_fir()?)?, - use_in_band_fec: ::core::convert::TryInto::try_into( - value.use_in_band_fec()?, - )?, - use_dtx: ::core::convert::TryInto::try_into(value.use_dtx()?)?, - spatial_layers: ::core::convert::TryInto::try_into( - value.spatial_layers()?, - )?, - temporal_layers: ::core::convert::TryInto::try_into( - value.temporal_layers()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ParamsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ParamsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ParamsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Params { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ParamsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ParamsRef]", "read_as_root", 0) - }) - } - } - - /// The table `Dump` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/rtpStream.fbs:25` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Dump { - /// The field `params` in the table `Dump` - pub params: ::planus::alloc::boxed::Box, - /// The field `score` in the table `Dump` - pub score: u8, - /// The field `rtx_stream` in the table `Dump` - pub rtx_stream: - ::core::option::Option<::planus::alloc::boxed::Box>, - } - - impl Dump { - /// Creates a [DumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpBuilder<()> { - DumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_params: impl ::planus::WriteAs<::planus::Offset>, - field_score: impl ::planus::WriteAsDefault, - field_rtx_stream: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_params = field_params.prepare(builder); - let prepared_score = field_score.prepare(builder, &0); - let prepared_rtx_stream = field_rtx_stream.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_rtx_stream.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_score.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_params); - if let ::core::option::Option::Some(prepared_rtx_stream) = - prepared_rtx_stream - { - object_writer.write::<_, _, 4>(&prepared_rtx_stream); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - object_writer.write::<_, _, 1>(&prepared_score); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Dump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Dump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Dump { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Dump::create(builder, &self.params, self.score, &self.rtx_stream) - } - } - - /// Builder for serializing an instance of the [Dump] type. - /// - /// Can be created using the [Dump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpBuilder(State); - - impl DumpBuilder<()> { - /// Setter for the [`params` field](Dump#structfield.params). - #[inline] - #[allow(clippy::type_complexity)] - pub fn params(self, value: T0) -> DumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpBuilder((value,)) - } - } - - impl DumpBuilder<(T0,)> { - /// Setter for the [`score` field](Dump#structfield.score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn score(self, value: T1) -> DumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DumpBuilder((v0, value)) - } - - /// Sets the [`score` field](Dump#structfield.score) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn score_as_default(self) -> DumpBuilder<(T0, ::planus::DefaultValue)> { - self.score(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1)> { - /// Setter for the [`rtx_stream` field](Dump#structfield.rtx_stream). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_stream(self, value: T2) -> DumpBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1) = self.0; - DumpBuilder((v0, v1, value)) - } - - /// Sets the [`rtx_stream` field](Dump#structfield.rtx_stream) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_stream_as_null(self) -> DumpBuilder<(T0, T1, ())> { - self.rtx_stream(()) - } - } - - impl DumpBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Dump]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> for DumpBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> for DumpBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOffset for DumpBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - Dump::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [Dump]. - #[derive(Copy, Clone)] - pub struct DumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpRef<'a> { - /// Getter for the [`params` field](Dump#structfield.params). - #[inline] - pub fn params(&self) -> ::planus::Result> { - self.0.access_required(0, "Dump", "params") - } - - /// Getter for the [`score` field](Dump#structfield.score). - #[inline] - pub fn score(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Dump", "score")?.unwrap_or(0)) - } - - /// Getter for the [`rtx_stream` field](Dump#structfield.rtx_stream). - #[inline] - pub fn rtx_stream( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(2, "Dump", "rtx_stream") - } - } - - impl<'a> ::core::fmt::Debug for DumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpRef"); - f.field("params", &self.params()); - f.field("score", &self.score()); - if let ::core::option::Option::Some(field_rtx_stream) = - self.rtx_stream().transpose() - { - f.field("rtx_stream", &field_rtx_stream); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Dump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - params: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.params()?)?, - ), - score: ::core::convert::TryInto::try_into(value.score()?)?, - rtx_stream: if let ::core::option::Option::Some(rtx_stream) = - value.rtx_stream()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtx_stream)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location("[DumpRef]", "get", buffer.offset_from_start) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Dump { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpRef]", "read_as_root", 0) - }) - } - } - - /// The table `BitrateByLayer` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `BitrateByLayer` in the file `../worker/fbs/rtpStream.fbs:31` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct BitrateByLayer { - /// The field `layer` in the table `BitrateByLayer` - pub layer: ::planus::alloc::string::String, - /// The field `bitrate` in the table `BitrateByLayer` - pub bitrate: u32, - } - - impl BitrateByLayer { - /// Creates a [BitrateByLayerBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BitrateByLayerBuilder<()> { - BitrateByLayerBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_layer: impl ::planus::WriteAs<::planus::Offset>, - field_bitrate: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_layer = field_layer.prepare(builder); - let prepared_bitrate = field_bitrate.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_bitrate.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_layer); - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate - { - object_writer.write::<_, _, 4>(&prepared_bitrate); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for BitrateByLayer { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for BitrateByLayer { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for BitrateByLayer { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - BitrateByLayer::create(builder, &self.layer, self.bitrate) - } - } - - /// Builder for serializing an instance of the [BitrateByLayer] type. - /// - /// Can be created using the [BitrateByLayer::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BitrateByLayerBuilder(State); - - impl BitrateByLayerBuilder<()> { - /// Setter for the [`layer` field](BitrateByLayer#structfield.layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn layer(self, value: T0) -> BitrateByLayerBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - BitrateByLayerBuilder((value,)) - } - } - - impl BitrateByLayerBuilder<(T0,)> { - /// Setter for the [`bitrate` field](BitrateByLayer#structfield.bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate(self, value: T1) -> BitrateByLayerBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - BitrateByLayerBuilder((v0, value)) - } - - /// Sets the [`bitrate` field](BitrateByLayer#structfield.bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate_as_default( - self, - ) -> BitrateByLayerBuilder<(T0, ::planus::DefaultValue)> { - self.bitrate(::planus::DefaultValue) - } - } - - impl BitrateByLayerBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BitrateByLayer]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for BitrateByLayerBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for BitrateByLayerBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for BitrateByLayerBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - BitrateByLayer::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [BitrateByLayer]. - #[derive(Copy, Clone)] - pub struct BitrateByLayerRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BitrateByLayerRef<'a> { - /// Getter for the [`layer` field](BitrateByLayer#structfield.layer). - #[inline] - pub fn layer(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "BitrateByLayer", "layer") - } - - /// Getter for the [`bitrate` field](BitrateByLayer#structfield.bitrate). - #[inline] - pub fn bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "BitrateByLayer", "bitrate")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for BitrateByLayerRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BitrateByLayerRef"); - f.field("layer", &self.layer()); - f.field("bitrate", &self.bitrate()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for BitrateByLayer { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: BitrateByLayerRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - layer: ::core::convert::TryInto::try_into(value.layer()?)?, - bitrate: ::core::convert::TryInto::try_into(value.bitrate()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for BitrateByLayerRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for BitrateByLayerRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[BitrateByLayerRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for BitrateByLayer { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for BitrateByLayerRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[BitrateByLayerRef]", "read_as_root", 0) - }) - } - } - - /// The union `StatsData` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Union `StatsData` in the file `../worker/fbs/rtpStream.fbs:36` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub enum StatsData { - /// The variant of type `BaseStats` in the union `StatsData` - BaseStats(::planus::alloc::boxed::Box), - - /// The variant of type `RecvStats` in the union `StatsData` - RecvStats(::planus::alloc::boxed::Box), - - /// The variant of type `SendStats` in the union `StatsData` - SendStats(::planus::alloc::boxed::Box), - } - - impl StatsData { - /// Creates a [StatsDataBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StatsDataBuilder<::planus::Uninitialized> { - StatsDataBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_base_stats( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_recv_stats( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_send_stats( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for StatsData { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::BaseStats(value) => Self::create_base_stats(builder, value), - Self::RecvStats(value) => Self::create_recv_stats(builder, value), - Self::SendStats(value) => Self::create_send_stats(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for StatsData { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [StatsData] type. - /// - /// Can be created using the [StatsData::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StatsDataBuilder(T); - - impl StatsDataBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`BaseStats` variant](StatsData#variant.BaseStats). - #[inline] - pub fn base_stats( - self, - value: T, - ) -> StatsDataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - StatsDataBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RecvStats` variant](StatsData#variant.RecvStats). - #[inline] - pub fn recv_stats( - self, - value: T, - ) -> StatsDataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - StatsDataBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`SendStats` variant](StatsData#variant.SendStats). - #[inline] - pub fn send_stats( - self, - value: T, - ) -> StatsDataBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - StatsDataBuilder(::planus::Initialized(value)) - } - } - - impl StatsDataBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [StatsData]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for StatsDataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for StatsDataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for StatsDataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for StatsDataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for StatsDataBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for StatsDataBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [StatsData]. - #[derive(Copy, Clone, Debug)] - pub enum StatsDataRef<'a> { - BaseStats(self::BaseStatsRef<'a>), - RecvStats(self::RecvStatsRef<'a>), - SendStats(self::SendStatsRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for StatsData { - type Error = ::planus::Error; - - fn try_from(value: StatsDataRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - StatsDataRef::BaseStats(value) => { - Self::BaseStats(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - StatsDataRef::RecvStats(value) => { - Self::RecvStats(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - StatsDataRef::SendStats(value) => { - Self::SendStats(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for StatsDataRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::BaseStats( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::RecvStats( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::SendStats( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `Stats` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/rtpStream.fbs:42` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Stats { - /// The field `data` in the table `Stats` - pub data: self::StatsData, - } - - impl Stats { - /// Creates a [StatsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StatsBuilder<()> { - StatsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAsUnion, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(1); - table_writer.write_entry::(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data.offset()); - object_writer.write::<_, _, 1>(&prepared_data.tag()); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Stats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Stats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Stats { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Stats::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [Stats] type. - /// - /// Can be created using the [Stats::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StatsBuilder(State); - - impl StatsBuilder<()> { - /// Setter for the [`data` field](Stats#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> StatsBuilder<(T0,)> - where - T0: ::planus::WriteAsUnion, - { - StatsBuilder((value,)) - } - } - - impl StatsBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Stats]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> for StatsBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> for StatsBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for StatsBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Stats::create(builder, v0) - } - } - - /// Reference to a deserialized [Stats]. - #[derive(Copy, Clone)] - pub struct StatsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> StatsRef<'a> { - /// Getter for the [`data` field](Stats#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_union_required(0, "Stats", "data") - } - } - - impl<'a> ::core::fmt::Debug for StatsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("StatsRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Stats { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: StatsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: ::core::convert::TryInto::try_into(value.data()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for StatsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for StatsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[StatsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Stats { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for StatsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[StatsRef]", "read_as_root", 0) - }) - } - } - - /// The table `BaseStats` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `BaseStats` in the file `../worker/fbs/rtpStream.fbs:46` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct BaseStats { - /// The field `timestamp` in the table `BaseStats` - pub timestamp: u64, - /// The field `ssrc` in the table `BaseStats` - pub ssrc: u32, - /// The field `kind` in the table `BaseStats` - pub kind: super::rtp_parameters::MediaKind, - /// The field `mime_type` in the table `BaseStats` - pub mime_type: ::planus::alloc::string::String, - /// The field `packets_lost` in the table `BaseStats` - pub packets_lost: u64, - /// The field `fraction_lost` in the table `BaseStats` - pub fraction_lost: u8, - /// The field `packets_discarded` in the table `BaseStats` - pub packets_discarded: u64, - /// The field `packets_retransmitted` in the table `BaseStats` - pub packets_retransmitted: u64, - /// The field `packets_repaired` in the table `BaseStats` - pub packets_repaired: u64, - /// The field `nack_count` in the table `BaseStats` - pub nack_count: u64, - /// The field `nack_packet_count` in the table `BaseStats` - pub nack_packet_count: u64, - /// The field `pli_count` in the table `BaseStats` - pub pli_count: u64, - /// The field `fir_count` in the table `BaseStats` - pub fir_count: u64, - /// The field `score` in the table `BaseStats` - pub score: u8, - /// The field `rid` in the table `BaseStats` - pub rid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `rtx_ssrc` in the table `BaseStats` - pub rtx_ssrc: ::core::option::Option, - /// The field `rtx_packets_discarded` in the table `BaseStats` - pub rtx_packets_discarded: u64, - /// The field `round_trip_time` in the table `BaseStats` - pub round_trip_time: f32, - } - - impl BaseStats { - /// Creates a [BaseStatsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BaseStatsBuilder<()> { - BaseStatsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_timestamp: impl ::planus::WriteAsDefault, - field_ssrc: impl ::planus::WriteAsDefault, - field_kind: impl ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - field_mime_type: impl ::planus::WriteAs<::planus::Offset>, - field_packets_lost: impl ::planus::WriteAsDefault, - field_fraction_lost: impl ::planus::WriteAsDefault, - field_packets_discarded: impl ::planus::WriteAsDefault, - field_packets_retransmitted: impl ::planus::WriteAsDefault, - field_packets_repaired: impl ::planus::WriteAsDefault, - field_nack_count: impl ::planus::WriteAsDefault, - field_nack_packet_count: impl ::planus::WriteAsDefault, - field_pli_count: impl ::planus::WriteAsDefault, - field_fir_count: impl ::planus::WriteAsDefault, - field_score: impl ::planus::WriteAsDefault, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_rtx_ssrc: impl ::planus::WriteAsOptional, - field_rtx_packets_discarded: impl ::planus::WriteAsDefault, - field_round_trip_time: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_ssrc = field_ssrc.prepare(builder, &0); - let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::Audio); - let prepared_mime_type = field_mime_type.prepare(builder); - let prepared_packets_lost = field_packets_lost.prepare(builder, &0); - let prepared_fraction_lost = field_fraction_lost.prepare(builder, &0); - let prepared_packets_discarded = field_packets_discarded.prepare(builder, &0); - let prepared_packets_retransmitted = - field_packets_retransmitted.prepare(builder, &0); - let prepared_packets_repaired = field_packets_repaired.prepare(builder, &0); - let prepared_nack_count = field_nack_count.prepare(builder, &0); - let prepared_nack_packet_count = field_nack_packet_count.prepare(builder, &0); - let prepared_pli_count = field_pli_count.prepare(builder, &0); - let prepared_fir_count = field_fir_count.prepare(builder, &0); - let prepared_score = field_score.prepare(builder, &0); - let prepared_rid = field_rid.prepare(builder); - let prepared_rtx_ssrc = field_rtx_ssrc.prepare(builder); - let prepared_rtx_packets_discarded = - field_rtx_packets_discarded.prepare(builder, &0); - let prepared_round_trip_time = field_round_trip_time.prepare(builder, &0.0); - - let mut table_writer: ::planus::table_writer::TableWriter<40> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(0); - } - if prepared_packets_lost.is_some() { - table_writer.write_entry::(4); - } - if prepared_packets_discarded.is_some() { - table_writer.write_entry::(6); - } - if prepared_packets_retransmitted.is_some() { - table_writer.write_entry::(7); - } - if prepared_packets_repaired.is_some() { - table_writer.write_entry::(8); - } - if prepared_nack_count.is_some() { - table_writer.write_entry::(9); - } - if prepared_nack_packet_count.is_some() { - table_writer.write_entry::(10); - } - if prepared_pli_count.is_some() { - table_writer.write_entry::(11); - } - if prepared_fir_count.is_some() { - table_writer.write_entry::(12); - } - if prepared_rtx_packets_discarded.is_some() { - table_writer.write_entry::(16); - } - if prepared_ssrc.is_some() { - table_writer.write_entry::(1); - } - table_writer.write_entry::<::planus::Offset>(3); - if prepared_rid.is_some() { - table_writer.write_entry::<::planus::Offset>(14); - } - if prepared_rtx_ssrc.is_some() { - table_writer.write_entry::(15); - } - if prepared_round_trip_time.is_some() { - table_writer.write_entry::(17); - } - if prepared_kind.is_some() { - table_writer.write_entry::(2); - } - if prepared_fraction_lost.is_some() { - table_writer.write_entry::(5); - } - if prepared_score.is_some() { - table_writer.write_entry::(13); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_packets_lost) = - prepared_packets_lost - { - object_writer.write::<_, _, 8>(&prepared_packets_lost); - } - if let ::core::option::Option::Some(prepared_packets_discarded) = - prepared_packets_discarded - { - object_writer.write::<_, _, 8>(&prepared_packets_discarded); - } - if let ::core::option::Option::Some(prepared_packets_retransmitted) = - prepared_packets_retransmitted - { - object_writer.write::<_, _, 8>(&prepared_packets_retransmitted); - } - if let ::core::option::Option::Some(prepared_packets_repaired) = - prepared_packets_repaired - { - object_writer.write::<_, _, 8>(&prepared_packets_repaired); - } - if let ::core::option::Option::Some(prepared_nack_count) = - prepared_nack_count - { - object_writer.write::<_, _, 8>(&prepared_nack_count); - } - if let ::core::option::Option::Some(prepared_nack_packet_count) = - prepared_nack_packet_count - { - object_writer.write::<_, _, 8>(&prepared_nack_packet_count); - } - if let ::core::option::Option::Some(prepared_pli_count) = - prepared_pli_count - { - object_writer.write::<_, _, 8>(&prepared_pli_count); - } - if let ::core::option::Option::Some(prepared_fir_count) = - prepared_fir_count - { - object_writer.write::<_, _, 8>(&prepared_fir_count); - } - if let ::core::option::Option::Some(prepared_rtx_packets_discarded) = - prepared_rtx_packets_discarded - { - object_writer.write::<_, _, 8>(&prepared_rtx_packets_discarded); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - object_writer.write::<_, _, 4>(&prepared_mime_type); - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 4>(&prepared_rid); - } - if let ::core::option::Option::Some(prepared_rtx_ssrc) = - prepared_rtx_ssrc - { - object_writer.write::<_, _, 4>(&prepared_rtx_ssrc); - } - if let ::core::option::Option::Some(prepared_round_trip_time) = - prepared_round_trip_time - { - object_writer.write::<_, _, 4>(&prepared_round_trip_time); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - object_writer.write::<_, _, 1>(&prepared_kind); - } - if let ::core::option::Option::Some(prepared_fraction_lost) = - prepared_fraction_lost - { - object_writer.write::<_, _, 1>(&prepared_fraction_lost); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - object_writer.write::<_, _, 1>(&prepared_score); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for BaseStats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for BaseStats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for BaseStats { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - BaseStats::create( - builder, - self.timestamp, - self.ssrc, - self.kind, - &self.mime_type, - self.packets_lost, - self.fraction_lost, - self.packets_discarded, - self.packets_retransmitted, - self.packets_repaired, - self.nack_count, - self.nack_packet_count, - self.pli_count, - self.fir_count, - self.score, - &self.rid, - self.rtx_ssrc, - self.rtx_packets_discarded, - self.round_trip_time, - ) - } - } - - /// Builder for serializing an instance of the [BaseStats] type. - /// - /// Can be created using the [BaseStats::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BaseStatsBuilder(State); - - impl BaseStatsBuilder<()> { - /// Setter for the [`timestamp` field](BaseStats#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T0) -> BaseStatsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - BaseStatsBuilder((value,)) - } - - /// Sets the [`timestamp` field](BaseStats#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default(self) -> BaseStatsBuilder<(::planus::DefaultValue,)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0,)> { - /// Setter for the [`ssrc` field](BaseStats#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T1) -> BaseStatsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - BaseStatsBuilder((v0, value)) - } - - /// Sets the [`ssrc` field](BaseStats#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> BaseStatsBuilder<(T0, ::planus::DefaultValue)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1)> { - /// Setter for the [`kind` field](BaseStats#structfield.kind). - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind(self, value: T2) -> BaseStatsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - { - let (v0, v1) = self.0; - BaseStatsBuilder((v0, v1, value)) - } - - /// Sets the [`kind` field](BaseStats#structfield.kind) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind_as_default(self) -> BaseStatsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.kind(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1, T2)> { - /// Setter for the [`mime_type` field](BaseStats#structfield.mime_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mime_type(self, value: T3) -> BaseStatsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - BaseStatsBuilder((v0, v1, v2, value)) - } - } - - impl BaseStatsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`packets_lost` field](BaseStats#structfield.packets_lost). - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_lost(self, value: T4) -> BaseStatsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`packets_lost` field](BaseStats#structfield.packets_lost) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_lost_as_default( - self, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.packets_lost(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`fraction_lost` field](BaseStats#structfield.fraction_lost). - #[inline] - #[allow(clippy::type_complexity)] - pub fn fraction_lost( - self, - value: T5, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`fraction_lost` field](BaseStats#structfield.fraction_lost) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn fraction_lost_as_default( - self, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.fraction_lost(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`packets_discarded` field](BaseStats#structfield.packets_discarded). - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_discarded( - self, - value: T6, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`packets_discarded` field](BaseStats#structfield.packets_discarded) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_discarded_as_default( - self, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.packets_discarded(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`packets_retransmitted` field](BaseStats#structfield.packets_retransmitted). - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_retransmitted( - self, - value: T7, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`packets_retransmitted` field](BaseStats#structfield.packets_retransmitted) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_retransmitted_as_default( - self, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.packets_retransmitted(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`packets_repaired` field](BaseStats#structfield.packets_repaired). - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_repaired( - self, - value: T8, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`packets_repaired` field](BaseStats#structfield.packets_repaired) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn packets_repaired_as_default( - self, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> - { - self.packets_repaired(::planus::DefaultValue) - } - } - - impl BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`nack_count` field](BaseStats#structfield.nack_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn nack_count( - self, - value: T9, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - - /// Sets the [`nack_count` field](BaseStats#structfield.nack_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn nack_count_as_default( - self, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, ::planus::DefaultValue)> - { - self.nack_count(::planus::DefaultValue) - } - } - - impl - BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - /// Setter for the [`nack_packet_count` field](BaseStats#structfield.nack_packet_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn nack_packet_count( - self, - value: T10, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`nack_packet_count` field](BaseStats#structfield.nack_packet_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn nack_packet_count_as_default( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - ::planus::DefaultValue, - )> { - self.nack_packet_count(::planus::DefaultValue) - } - } - - impl - BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Setter for the [`pli_count` field](BaseStats#structfield.pli_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn pli_count( - self, - value: T11, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - where - T11: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, value)) - } - - /// Sets the [`pli_count` field](BaseStats#structfield.pli_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn pli_count_as_default( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - ::planus::DefaultValue, - )> { - self.pli_count(::planus::DefaultValue) - } - } - - impl - BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`fir_count` field](BaseStats#structfield.fir_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn fir_count( - self, - value: T12, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - where - T12: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, value)) - } - - /// Sets the [`fir_count` field](BaseStats#structfield.fir_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn fir_count_as_default( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - ::planus::DefaultValue, - )> { - self.fir_count(::planus::DefaultValue) - } - } - - impl - BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - { - /// Setter for the [`score` field](BaseStats#structfield.score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn score( - self, - value: T13, - ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - where - T13: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) = self.0; - BaseStatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, value)) - } - - /// Sets the [`score` field](BaseStats#structfield.score) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn score_as_default( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - ::planus::DefaultValue, - )> { - self.score(::planus::DefaultValue) - } - } - - impl - BaseStatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - /// Setter for the [`rid` field](BaseStats#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid( - self, - value: T14, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - where - T14: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) = self.0; - BaseStatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, value, - )) - } - - /// Sets the [`rid` field](BaseStats#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - (), - )> { - self.rid(()) - } - } - - impl - BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - /// Setter for the [`rtx_ssrc` field](BaseStats#structfield.rtx_ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_ssrc( - self, - value: T15, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - where - T15: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) = self.0; - BaseStatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, value, - )) - } - - /// Sets the [`rtx_ssrc` field](BaseStats#structfield.rtx_ssrc) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_ssrc_as_null( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - (), - )> { - self.rtx_ssrc(()) - } - } - - impl - BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - /// Setter for the [`rtx_packets_discarded` field](BaseStats#structfield.rtx_packets_discarded). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_packets_discarded( - self, - value: T16, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - )> - where - T16: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) = - self.0; - BaseStatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, value, - )) - } - - /// Sets the [`rtx_packets_discarded` field](BaseStats#structfield.rtx_packets_discarded) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_packets_discarded_as_default( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - ::planus::DefaultValue, - )> { - self.rtx_packets_discarded(::planus::DefaultValue) - } - } - - impl - BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - )> - { - /// Setter for the [`round_trip_time` field](BaseStats#structfield.round_trip_time). - #[inline] - #[allow(clippy::type_complexity)] - pub fn round_trip_time( - self, - value: T17, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - where - T17: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) = - self.0; - BaseStatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - value, - )) - } - - /// Sets the [`round_trip_time` field](BaseStats#structfield.round_trip_time) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn round_trip_time_as_default( - self, - ) -> BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - ::planus::DefaultValue, - )> { - self.round_trip_time(::planus::DefaultValue) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - > - BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BaseStats]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T15: ::planus::WriteAsOptional, - T16: ::planus::WriteAsDefault, - T17: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T15: ::planus::WriteAsOptional, - T16: ::planus::WriteAsDefault, - T17: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T15: ::planus::WriteAsOptional, - T16: ::planus::WriteAsDefault, - T17: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for BaseStatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - ) = &self.0; - BaseStats::create( - builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, - v15, v16, v17, - ) - } - } - - /// Reference to a deserialized [BaseStats]. - #[derive(Copy, Clone)] - pub struct BaseStatsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BaseStatsRef<'a> { - /// Getter for the [`timestamp` field](BaseStats#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "BaseStats", "timestamp")?.unwrap_or(0), - ) - } - - /// Getter for the [`ssrc` field](BaseStats#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "BaseStats", "ssrc")?.unwrap_or(0)) - } - - /// Getter for the [`kind` field](BaseStats#structfield.kind). - #[inline] - pub fn kind(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "BaseStats", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::Audio), - ) - } - - /// Getter for the [`mime_type` field](BaseStats#structfield.mime_type). - #[inline] - pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(3, "BaseStats", "mime_type") - } - - /// Getter for the [`packets_lost` field](BaseStats#structfield.packets_lost). - #[inline] - pub fn packets_lost(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(4, "BaseStats", "packets_lost")?.unwrap_or(0), - ) - } - - /// Getter for the [`fraction_lost` field](BaseStats#structfield.fraction_lost). - #[inline] - pub fn fraction_lost(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(5, "BaseStats", "fraction_lost")?.unwrap_or(0), - ) - } - - /// Getter for the [`packets_discarded` field](BaseStats#structfield.packets_discarded). - #[inline] - pub fn packets_discarded(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "BaseStats", "packets_discarded")? - .unwrap_or(0), - ) - } - - /// Getter for the [`packets_retransmitted` field](BaseStats#structfield.packets_retransmitted). - #[inline] - pub fn packets_retransmitted(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "BaseStats", "packets_retransmitted")? - .unwrap_or(0), - ) - } - - /// Getter for the [`packets_repaired` field](BaseStats#structfield.packets_repaired). - #[inline] - pub fn packets_repaired(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(8, "BaseStats", "packets_repaired")? - .unwrap_or(0), - ) - } - - /// Getter for the [`nack_count` field](BaseStats#structfield.nack_count). - #[inline] - pub fn nack_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(9, "BaseStats", "nack_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`nack_packet_count` field](BaseStats#structfield.nack_packet_count). - #[inline] - pub fn nack_packet_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(10, "BaseStats", "nack_packet_count")? - .unwrap_or(0), - ) - } - - /// Getter for the [`pli_count` field](BaseStats#structfield.pli_count). - #[inline] - pub fn pli_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(11, "BaseStats", "pli_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`fir_count` field](BaseStats#structfield.fir_count). - #[inline] - pub fn fir_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(12, "BaseStats", "fir_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`score` field](BaseStats#structfield.score). - #[inline] - pub fn score(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(13, "BaseStats", "score")?.unwrap_or(0), - ) - } - - /// Getter for the [`rid` field](BaseStats#structfield.rid). - #[inline] - pub fn rid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(14, "BaseStats", "rid") - } - - /// Getter for the [`rtx_ssrc` field](BaseStats#structfield.rtx_ssrc). - #[inline] - pub fn rtx_ssrc(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(15, "BaseStats", "rtx_ssrc") - } - - /// Getter for the [`rtx_packets_discarded` field](BaseStats#structfield.rtx_packets_discarded). - #[inline] - pub fn rtx_packets_discarded(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(16, "BaseStats", "rtx_packets_discarded")? - .unwrap_or(0), - ) - } - - /// Getter for the [`round_trip_time` field](BaseStats#structfield.round_trip_time). - #[inline] - pub fn round_trip_time(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(17, "BaseStats", "round_trip_time")? - .unwrap_or(0.0), - ) - } - } - - impl<'a> ::core::fmt::Debug for BaseStatsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BaseStatsRef"); - f.field("timestamp", &self.timestamp()); - f.field("ssrc", &self.ssrc()); - f.field("kind", &self.kind()); - f.field("mime_type", &self.mime_type()); - f.field("packets_lost", &self.packets_lost()); - f.field("fraction_lost", &self.fraction_lost()); - f.field("packets_discarded", &self.packets_discarded()); - f.field("packets_retransmitted", &self.packets_retransmitted()); - f.field("packets_repaired", &self.packets_repaired()); - f.field("nack_count", &self.nack_count()); - f.field("nack_packet_count", &self.nack_packet_count()); - f.field("pli_count", &self.pli_count()); - f.field("fir_count", &self.fir_count()); - f.field("score", &self.score()); - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - if let ::core::option::Option::Some(field_rtx_ssrc) = - self.rtx_ssrc().transpose() - { - f.field("rtx_ssrc", &field_rtx_ssrc); - } - f.field("rtx_packets_discarded", &self.rtx_packets_discarded()); - f.field("round_trip_time", &self.round_trip_time()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for BaseStats { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: BaseStatsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - kind: ::core::convert::TryInto::try_into(value.kind()?)?, - mime_type: ::core::convert::TryInto::try_into(value.mime_type()?)?, - packets_lost: ::core::convert::TryInto::try_into(value.packets_lost()?)?, - fraction_lost: ::core::convert::TryInto::try_into(value.fraction_lost()?)?, - packets_discarded: ::core::convert::TryInto::try_into( - value.packets_discarded()?, - )?, - packets_retransmitted: ::core::convert::TryInto::try_into( - value.packets_retransmitted()?, - )?, - packets_repaired: ::core::convert::TryInto::try_into( - value.packets_repaired()?, - )?, - nack_count: ::core::convert::TryInto::try_into(value.nack_count()?)?, - nack_packet_count: ::core::convert::TryInto::try_into( - value.nack_packet_count()?, - )?, - pli_count: ::core::convert::TryInto::try_into(value.pli_count()?)?, - fir_count: ::core::convert::TryInto::try_into(value.fir_count()?)?, - score: ::core::convert::TryInto::try_into(value.score()?)?, - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - rtx_ssrc: if let ::core::option::Option::Some(rtx_ssrc) = - value.rtx_ssrc()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - rtx_ssrc, - )?) - } else { - ::core::option::Option::None - }, - rtx_packets_discarded: ::core::convert::TryInto::try_into( - value.rtx_packets_discarded()?, - )?, - round_trip_time: ::core::convert::TryInto::try_into( - value.round_trip_time()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for BaseStatsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for BaseStatsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[BaseStatsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for BaseStats { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for BaseStatsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[BaseStatsRef]", "read_as_root", 0) - }) - } - } - - /// The table `RecvStats` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `RecvStats` in the file `../worker/fbs/rtpStream.fbs:67` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct RecvStats { - /// The field `base` in the table `RecvStats` - pub base: ::planus::alloc::boxed::Box, - /// The field `jitter` in the table `RecvStats` - pub jitter: u32, - /// The field `packet_count` in the table `RecvStats` - pub packet_count: u64, - /// The field `byte_count` in the table `RecvStats` - pub byte_count: u64, - /// The field `bitrate` in the table `RecvStats` - pub bitrate: u32, - /// The field `bitrate_by_layer` in the table `RecvStats` - pub bitrate_by_layer: ::planus::alloc::vec::Vec, - } - - impl RecvStats { - /// Creates a [RecvStatsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RecvStatsBuilder<()> { - RecvStatsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_jitter: impl ::planus::WriteAsDefault, - field_packet_count: impl ::planus::WriteAsDefault, - field_byte_count: impl ::planus::WriteAsDefault, - field_bitrate: impl ::planus::WriteAsDefault, - field_bitrate_by_layer: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_jitter = field_jitter.prepare(builder, &0); - let prepared_packet_count = field_packet_count.prepare(builder, &0); - let prepared_byte_count = field_byte_count.prepare(builder, &0); - let prepared_bitrate = field_bitrate.prepare(builder, &0); - let prepared_bitrate_by_layer = field_bitrate_by_layer.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - if prepared_packet_count.is_some() { - table_writer.write_entry::(2); - } - if prepared_byte_count.is_some() { - table_writer.write_entry::(3); - } - table_writer.write_entry::<::planus::Offset>(0); - if prepared_jitter.is_some() { - table_writer.write_entry::(1); - } - if prepared_bitrate.is_some() { - table_writer.write_entry::(4); - } - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>( - 5, - ); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_packet_count) = - prepared_packet_count - { - object_writer.write::<_, _, 8>(&prepared_packet_count); - } - if let ::core::option::Option::Some(prepared_byte_count) = - prepared_byte_count - { - object_writer.write::<_, _, 8>(&prepared_byte_count); - } - object_writer.write::<_, _, 4>(&prepared_base); - if let ::core::option::Option::Some(prepared_jitter) = prepared_jitter { - object_writer.write::<_, _, 4>(&prepared_jitter); - } - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate - { - object_writer.write::<_, _, 4>(&prepared_bitrate); - } - object_writer.write::<_, _, 4>(&prepared_bitrate_by_layer); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RecvStats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RecvStats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RecvStats { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - RecvStats::create( - builder, - &self.base, - self.jitter, - self.packet_count, - self.byte_count, - self.bitrate, - &self.bitrate_by_layer, - ) - } - } - - /// Builder for serializing an instance of the [RecvStats] type. - /// - /// Can be created using the [RecvStats::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RecvStatsBuilder(State); - - impl RecvStatsBuilder<()> { - /// Setter for the [`base` field](RecvStats#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> RecvStatsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RecvStatsBuilder((value,)) - } - } - - impl RecvStatsBuilder<(T0,)> { - /// Setter for the [`jitter` field](RecvStats#structfield.jitter). - #[inline] - #[allow(clippy::type_complexity)] - pub fn jitter(self, value: T1) -> RecvStatsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RecvStatsBuilder((v0, value)) - } - - /// Sets the [`jitter` field](RecvStats#structfield.jitter) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn jitter_as_default(self) -> RecvStatsBuilder<(T0, ::planus::DefaultValue)> { - self.jitter(::planus::DefaultValue) - } - } - - impl RecvStatsBuilder<(T0, T1)> { - /// Setter for the [`packet_count` field](RecvStats#structfield.packet_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn packet_count(self, value: T2) -> RecvStatsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - RecvStatsBuilder((v0, v1, value)) - } - - /// Sets the [`packet_count` field](RecvStats#structfield.packet_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn packet_count_as_default( - self, - ) -> RecvStatsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.packet_count(::planus::DefaultValue) - } - } - - impl RecvStatsBuilder<(T0, T1, T2)> { - /// Setter for the [`byte_count` field](RecvStats#structfield.byte_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn byte_count(self, value: T3) -> RecvStatsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - RecvStatsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`byte_count` field](RecvStats#structfield.byte_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn byte_count_as_default( - self, - ) -> RecvStatsBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.byte_count(::planus::DefaultValue) - } - } - - impl RecvStatsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`bitrate` field](RecvStats#structfield.bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate(self, value: T4) -> RecvStatsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - RecvStatsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`bitrate` field](RecvStats#structfield.bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate_as_default( - self, - ) -> RecvStatsBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.bitrate(::planus::DefaultValue) - } - } - - impl RecvStatsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`bitrate_by_layer` field](RecvStats#structfield.bitrate_by_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate_by_layer( - self, - value: T5, - ) -> RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - RecvStatsBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RecvStats]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> - for RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset - for RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - RecvStats::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [RecvStats]. - #[derive(Copy, Clone)] - pub struct RecvStatsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RecvStatsRef<'a> { - /// Getter for the [`base` field](RecvStats#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "RecvStats", "base") - } - - /// Getter for the [`jitter` field](RecvStats#structfield.jitter). - #[inline] - pub fn jitter(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "RecvStats", "jitter")?.unwrap_or(0), - ) - } - - /// Getter for the [`packet_count` field](RecvStats#structfield.packet_count). - #[inline] - pub fn packet_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(2, "RecvStats", "packet_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`byte_count` field](RecvStats#structfield.byte_count). - #[inline] - pub fn byte_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "RecvStats", "byte_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`bitrate` field](RecvStats#structfield.bitrate). - #[inline] - pub fn bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(4, "RecvStats", "bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`bitrate_by_layer` field](RecvStats#structfield.bitrate_by_layer). - #[inline] - pub fn bitrate_by_layer( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(5, "RecvStats", "bitrate_by_layer") - } - } - - impl<'a> ::core::fmt::Debug for RecvStatsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RecvStatsRef"); - f.field("base", &self.base()); - f.field("jitter", &self.jitter()); - f.field("packet_count", &self.packet_count()); - f.field("byte_count", &self.byte_count()); - f.field("bitrate", &self.bitrate()); - f.field("bitrate_by_layer", &self.bitrate_by_layer()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RecvStats { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RecvStatsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - jitter: ::core::convert::TryInto::try_into(value.jitter()?)?, - packet_count: ::core::convert::TryInto::try_into(value.packet_count()?)?, - byte_count: ::core::convert::TryInto::try_into(value.byte_count()?)?, - bitrate: ::core::convert::TryInto::try_into(value.bitrate()?)?, - bitrate_by_layer: value.bitrate_by_layer()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RecvStatsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RecvStatsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RecvStatsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RecvStats { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RecvStatsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RecvStatsRef]", "read_as_root", 0) - }) - } - } - - /// The table `SendStats` in the namespace `FBS.RtpStream` - /// - /// Generated from these locations: - /// * Table `SendStats` in the file `../worker/fbs/rtpStream.fbs:76` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct SendStats { - /// The field `base` in the table `SendStats` - pub base: ::planus::alloc::boxed::Box, - /// The field `packet_count` in the table `SendStats` - pub packet_count: u64, - /// The field `byte_count` in the table `SendStats` - pub byte_count: u64, - /// The field `bitrate` in the table `SendStats` - pub bitrate: u32, - } - - impl SendStats { - /// Creates a [SendStatsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SendStatsBuilder<()> { - SendStatsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_packet_count: impl ::planus::WriteAsDefault, - field_byte_count: impl ::planus::WriteAsDefault, - field_bitrate: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_packet_count = field_packet_count.prepare(builder, &0); - let prepared_byte_count = field_byte_count.prepare(builder, &0); - let prepared_bitrate = field_bitrate.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_packet_count.is_some() { - table_writer.write_entry::(1); - } - if prepared_byte_count.is_some() { - table_writer.write_entry::(2); - } - table_writer.write_entry::<::planus::Offset>(0); - if prepared_bitrate.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_packet_count) = - prepared_packet_count - { - object_writer.write::<_, _, 8>(&prepared_packet_count); - } - if let ::core::option::Option::Some(prepared_byte_count) = - prepared_byte_count - { - object_writer.write::<_, _, 8>(&prepared_byte_count); - } - object_writer.write::<_, _, 4>(&prepared_base); - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate - { - object_writer.write::<_, _, 4>(&prepared_bitrate); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SendStats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SendStats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SendStats { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - SendStats::create( - builder, - &self.base, - self.packet_count, - self.byte_count, - self.bitrate, - ) - } - } - - /// Builder for serializing an instance of the [SendStats] type. - /// - /// Can be created using the [SendStats::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SendStatsBuilder(State); - - impl SendStatsBuilder<()> { - /// Setter for the [`base` field](SendStats#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> SendStatsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - SendStatsBuilder((value,)) - } - } - - impl SendStatsBuilder<(T0,)> { - /// Setter for the [`packet_count` field](SendStats#structfield.packet_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn packet_count(self, value: T1) -> SendStatsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - SendStatsBuilder((v0, value)) - } - - /// Sets the [`packet_count` field](SendStats#structfield.packet_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn packet_count_as_default( - self, - ) -> SendStatsBuilder<(T0, ::planus::DefaultValue)> { - self.packet_count(::planus::DefaultValue) - } - } - - impl SendStatsBuilder<(T0, T1)> { - /// Setter for the [`byte_count` field](SendStats#structfield.byte_count). - #[inline] - #[allow(clippy::type_complexity)] - pub fn byte_count(self, value: T2) -> SendStatsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - SendStatsBuilder((v0, v1, value)) - } - - /// Sets the [`byte_count` field](SendStats#structfield.byte_count) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn byte_count_as_default( - self, - ) -> SendStatsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.byte_count(::planus::DefaultValue) - } - } - - impl SendStatsBuilder<(T0, T1, T2)> { - /// Setter for the [`bitrate` field](SendStats#structfield.bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate(self, value: T3) -> SendStatsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - SendStatsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`bitrate` field](SendStats#structfield.bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate_as_default( - self, - ) -> SendStatsBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.bitrate(::planus::DefaultValue) - } - } - - impl SendStatsBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendStats]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for SendStatsBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for SendStatsBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for SendStatsBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - SendStats::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [SendStats]. - #[derive(Copy, Clone)] - pub struct SendStatsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SendStatsRef<'a> { - /// Getter for the [`base` field](SendStats#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "SendStats", "base") - } - - /// Getter for the [`packet_count` field](SendStats#structfield.packet_count). - #[inline] - pub fn packet_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "SendStats", "packet_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`byte_count` field](SendStats#structfield.byte_count). - #[inline] - pub fn byte_count(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(2, "SendStats", "byte_count")?.unwrap_or(0), - ) - } - - /// Getter for the [`bitrate` field](SendStats#structfield.bitrate). - #[inline] - pub fn bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "SendStats", "bitrate")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SendStatsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SendStatsRef"); - f.field("base", &self.base()); - f.field("packet_count", &self.packet_count()); - f.field("byte_count", &self.byte_count()); - f.field("bitrate", &self.bitrate()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SendStats { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SendStatsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - packet_count: ::core::convert::TryInto::try_into(value.packet_count()?)?, - byte_count: ::core::convert::TryInto::try_into(value.byte_count()?)?, - bitrate: ::core::convert::TryInto::try_into(value.bitrate()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SendStatsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SendStatsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SendStatsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SendStats { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SendStatsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SendStatsRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.RtxStream` - /// - /// Generated from these locations: - /// * File `../worker/fbs/rtxStream.fbs` - pub mod rtx_stream { - /// The table `Params` in the namespace `FBS.RtxStream` - /// - /// Generated from these locations: - /// * Table `Params` in the file `../worker/fbs/rtxStream.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Params { - /// The field `ssrc` in the table `Params` - pub ssrc: u32, - /// The field `payload_type` in the table `Params` - pub payload_type: u8, - /// The field `mime_type` in the table `Params` - pub mime_type: ::planus::alloc::string::String, - /// The field `clock_rate` in the table `Params` - pub clock_rate: u32, - /// The field `rrid` in the table `Params` - pub rrid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `cname` in the table `Params` - pub cname: ::planus::alloc::string::String, - } - - impl Params { - /// Creates a [ParamsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ParamsBuilder<()> { - ParamsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - field_payload_type: impl ::planus::WriteAsDefault, - field_mime_type: impl ::planus::WriteAs<::planus::Offset>, - field_clock_rate: impl ::planus::WriteAsDefault, - field_rrid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_cname: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - let prepared_payload_type = field_payload_type.prepare(builder, &0); - let prepared_mime_type = field_mime_type.prepare(builder); - let prepared_clock_rate = field_clock_rate.prepare(builder, &0); - let prepared_rrid = field_rrid.prepare(builder); - let prepared_cname = field_cname.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset>(2); - if prepared_clock_rate.is_some() { - table_writer.write_entry::(3); - } - if prepared_rrid.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - table_writer.write_entry::<::planus::Offset>(5); - if prepared_payload_type.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - object_writer.write::<_, _, 4>(&prepared_mime_type); - if let ::core::option::Option::Some(prepared_clock_rate) = - prepared_clock_rate - { - object_writer.write::<_, _, 4>(&prepared_clock_rate); - } - if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { - object_writer.write::<_, _, 4>(&prepared_rrid); - } - object_writer.write::<_, _, 4>(&prepared_cname); - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - object_writer.write::<_, _, 1>(&prepared_payload_type); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Params { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Params { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Params { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Params::create( - builder, - self.ssrc, - self.payload_type, - &self.mime_type, - self.clock_rate, - &self.rrid, - &self.cname, - ) - } - } - - /// Builder for serializing an instance of the [Params] type. - /// - /// Can be created using the [Params::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ParamsBuilder(State); - - impl ParamsBuilder<()> { - /// Setter for the [`ssrc` field](Params#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> ParamsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ParamsBuilder((value,)) - } - - /// Sets the [`ssrc` field](Params#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> ParamsBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0,)> { - /// Setter for the [`payload_type` field](Params#structfield.payload_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type(self, value: T1) -> ParamsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ParamsBuilder((v0, value)) - } - - /// Sets the [`payload_type` field](Params#structfield.payload_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn payload_type_as_default( - self, - ) -> ParamsBuilder<(T0, ::planus::DefaultValue)> { - self.payload_type(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0, T1)> { - /// Setter for the [`mime_type` field](Params#structfield.mime_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mime_type(self, value: T2) -> ParamsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - ParamsBuilder((v0, v1, value)) - } - } - - impl ParamsBuilder<(T0, T1, T2)> { - /// Setter for the [`clock_rate` field](Params#structfield.clock_rate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn clock_rate(self, value: T3) -> ParamsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - ParamsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`clock_rate` field](Params#structfield.clock_rate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn clock_rate_as_default( - self, - ) -> ParamsBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.clock_rate(::planus::DefaultValue) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rrid` field](Params#structfield.rrid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rrid(self, value: T4) -> ParamsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3) = self.0; - ParamsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`rrid` field](Params#structfield.rrid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rrid_as_null(self) -> ParamsBuilder<(T0, T1, T2, T3, ())> { - self.rrid(()) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`cname` field](Params#structfield.cname). - #[inline] - #[allow(clippy::type_complexity)] - pub fn cname(self, value: T5) -> ParamsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3, v4) = self.0; - ParamsBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl ParamsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Params]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for ParamsBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for ParamsBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for ParamsBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - Params::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [Params]. - #[derive(Copy, Clone)] - pub struct ParamsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ParamsRef<'a> { - /// Getter for the [`ssrc` field](Params#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Params", "ssrc")?.unwrap_or(0)) - } - - /// Getter for the [`payload_type` field](Params#structfield.payload_type). - #[inline] - pub fn payload_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "Params", "payload_type")?.unwrap_or(0), - ) - } - - /// Getter for the [`mime_type` field](Params#structfield.mime_type). - #[inline] - pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "Params", "mime_type") - } - - /// Getter for the [`clock_rate` field](Params#structfield.clock_rate). - #[inline] - pub fn clock_rate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "Params", "clock_rate")?.unwrap_or(0), - ) - } - - /// Getter for the [`rrid` field](Params#structfield.rrid). - #[inline] - pub fn rrid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(4, "Params", "rrid") - } - - /// Getter for the [`cname` field](Params#structfield.cname). - #[inline] - pub fn cname(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(5, "Params", "cname") - } - } - - impl<'a> ::core::fmt::Debug for ParamsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ParamsRef"); - f.field("ssrc", &self.ssrc()); - f.field("payload_type", &self.payload_type()); - f.field("mime_type", &self.mime_type()); - f.field("clock_rate", &self.clock_rate()); - if let ::core::option::Option::Some(field_rrid) = self.rrid().transpose() { - f.field("rrid", &field_rrid); - } - f.field("cname", &self.cname()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Params { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ParamsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - payload_type: ::core::convert::TryInto::try_into(value.payload_type()?)?, - mime_type: ::core::convert::TryInto::try_into(value.mime_type()?)?, - clock_rate: ::core::convert::TryInto::try_into(value.clock_rate()?)?, - rrid: if let ::core::option::Option::Some(rrid) = value.rrid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rrid)?) - } else { - ::core::option::Option::None - }, - cname: ::core::convert::TryInto::try_into(value.cname()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ParamsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ParamsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ParamsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Params { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ParamsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ParamsRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtxDump` in the namespace `FBS.RtxStream` - /// - /// Generated from these locations: - /// * Table `RtxDump` in the file `../worker/fbs/rtxStream.fbs:13` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtxDump { - /// The field `params` in the table `RtxDump` - pub params: ::planus::alloc::boxed::Box, - } - - impl RtxDump { - /// Creates a [RtxDumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtxDumpBuilder<()> { - RtxDumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_params: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_params = field_params.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_params); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtxDump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtxDump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtxDump { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - RtxDump::create(builder, &self.params) - } - } - - /// Builder for serializing an instance of the [RtxDump] type. - /// - /// Can be created using the [RtxDump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtxDumpBuilder(State); - - impl RtxDumpBuilder<()> { - /// Setter for the [`params` field](RtxDump#structfield.params). - #[inline] - #[allow(clippy::type_complexity)] - pub fn params(self, value: T0) -> RtxDumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtxDumpBuilder((value,)) - } - } - - impl RtxDumpBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtxDump]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> for RtxDumpBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> for RtxDumpBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for RtxDumpBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - RtxDump::create(builder, v0) - } - } - - /// Reference to a deserialized [RtxDump]. - #[derive(Copy, Clone)] - pub struct RtxDumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtxDumpRef<'a> { - /// Getter for the [`params` field](RtxDump#structfield.params). - #[inline] - pub fn params(&self) -> ::planus::Result> { - self.0.access_required(0, "RtxDump", "params") - } - } - - impl<'a> ::core::fmt::Debug for RtxDumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtxDumpRef"); - f.field("params", &self.params()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtxDump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtxDumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - params: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.params()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtxDumpRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtxDumpRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtxDumpRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtxDump { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtxDumpRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtxDumpRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/dataConsumer.fbs` - pub mod data_consumer { - /// The table `GetBufferedAmountResponse` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `GetBufferedAmountResponse` in the file `../worker/fbs/dataConsumer.fbs:7` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct GetBufferedAmountResponse { - /// The field `buffered_amount` in the table `GetBufferedAmountResponse` - pub buffered_amount: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for GetBufferedAmountResponse { - fn default() -> Self { - Self { buffered_amount: 0 } - } - } - - impl GetBufferedAmountResponse { - /// Creates a [GetBufferedAmountResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetBufferedAmountResponseBuilder<()> { - GetBufferedAmountResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_buffered_amount: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_buffered_amount = field_buffered_amount.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_buffered_amount.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - object_writer.write::<_, _, 4>(&prepared_buffered_amount); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetBufferedAmountResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for GetBufferedAmountResponse - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetBufferedAmountResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetBufferedAmountResponse::create(builder, self.buffered_amount) - } - } - - /// Builder for serializing an instance of the [GetBufferedAmountResponse] type. - /// - /// Can be created using the [GetBufferedAmountResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetBufferedAmountResponseBuilder(State); - - impl GetBufferedAmountResponseBuilder<()> { - /// Setter for the [`buffered_amount` field](GetBufferedAmountResponse#structfield.buffered_amount). - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount( - self, - value: T0, - ) -> GetBufferedAmountResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - GetBufferedAmountResponseBuilder((value,)) - } - - /// Sets the [`buffered_amount` field](GetBufferedAmountResponse#structfield.buffered_amount) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount_as_default( - self, - ) -> GetBufferedAmountResponseBuilder<(::planus::DefaultValue,)> { - self.buffered_amount(::planus::DefaultValue) - } - } - - impl GetBufferedAmountResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetBufferedAmountResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for GetBufferedAmountResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for GetBufferedAmountResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for GetBufferedAmountResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - GetBufferedAmountResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [GetBufferedAmountResponse]. - #[derive(Copy, Clone)] - pub struct GetBufferedAmountResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetBufferedAmountResponseRef<'a> { - /// Getter for the [`buffered_amount` field](GetBufferedAmountResponse#structfield.buffered_amount). - #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "GetBufferedAmountResponse", "buffered_amount")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for GetBufferedAmountResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetBufferedAmountResponseRef"); - f.field("buffered_amount", &self.buffered_amount()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetBufferedAmountResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetBufferedAmountResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - buffered_amount: ::core::convert::TryInto::try_into( - value.buffered_amount()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetBufferedAmountResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetBufferedAmountResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetBufferedAmountResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for GetBufferedAmountResponse - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetBufferedAmountResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[GetBufferedAmountResponseRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SetBufferedAmountLowThresholdRequest` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `SetBufferedAmountLowThresholdRequest` in the file `../worker/fbs/dataConsumer.fbs:11` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetBufferedAmountLowThresholdRequest { - /// The field `threshold` in the table `SetBufferedAmountLowThresholdRequest` - pub threshold: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetBufferedAmountLowThresholdRequest { - fn default() -> Self { - Self { threshold: 0 } - } - } - - impl SetBufferedAmountLowThresholdRequest { - /// Creates a [SetBufferedAmountLowThresholdRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetBufferedAmountLowThresholdRequestBuilder<()> { - SetBufferedAmountLowThresholdRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_threshold: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_threshold = field_threshold.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_threshold.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_threshold) = - prepared_threshold - { - object_writer.write::<_, _, 4>(&prepared_threshold); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for SetBufferedAmountLowThresholdRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetBufferedAmountLowThresholdRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset - for SetBufferedAmountLowThresholdRequest - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetBufferedAmountLowThresholdRequest::create(builder, self.threshold) - } - } - - /// Builder for serializing an instance of the [SetBufferedAmountLowThresholdRequest] type. - /// - /// Can be created using the [SetBufferedAmountLowThresholdRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetBufferedAmountLowThresholdRequestBuilder(State); - - impl SetBufferedAmountLowThresholdRequestBuilder<()> { - /// Setter for the [`threshold` field](SetBufferedAmountLowThresholdRequest#structfield.threshold). - #[inline] - #[allow(clippy::type_complexity)] - pub fn threshold( - self, - value: T0, - ) -> SetBufferedAmountLowThresholdRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SetBufferedAmountLowThresholdRequestBuilder((value,)) - } - - /// Sets the [`threshold` field](SetBufferedAmountLowThresholdRequest#structfield.threshold) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn threshold_as_default( - self, - ) -> SetBufferedAmountLowThresholdRequestBuilder<(::planus::DefaultValue,)> - { - self.threshold(::planus::DefaultValue) - } - } - - impl SetBufferedAmountLowThresholdRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetBufferedAmountLowThresholdRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for SetBufferedAmountLowThresholdRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for SetBufferedAmountLowThresholdRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for SetBufferedAmountLowThresholdRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetBufferedAmountLowThresholdRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetBufferedAmountLowThresholdRequest]. - #[derive(Copy, Clone)] - pub struct SetBufferedAmountLowThresholdRequestRef<'a>( - ::planus::table_reader::Table<'a>, - ); - - impl<'a> SetBufferedAmountLowThresholdRequestRef<'a> { - /// Getter for the [`threshold` field](SetBufferedAmountLowThresholdRequest#structfield.threshold). - #[inline] - pub fn threshold(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SetBufferedAmountLowThresholdRequest", "threshold")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SetBufferedAmountLowThresholdRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetBufferedAmountLowThresholdRequestRef"); - f.field("threshold", &self.threshold()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for SetBufferedAmountLowThresholdRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from( - value: SetBufferedAmountLowThresholdRequestRef<'a>, - ) -> ::planus::Result { - ::core::result::Result::Ok(Self { - threshold: ::core::convert::TryInto::try_into(value.threshold()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetBufferedAmountLowThresholdRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetBufferedAmountLowThresholdRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetBufferedAmountLowThresholdRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SetBufferedAmountLowThresholdRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetBufferedAmountLowThresholdRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetBufferedAmountLowThresholdRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/dataConsumer.fbs:15` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `id` in the table `DumpResponse` - pub id: ::planus::alloc::string::String, - /// The field `data_producer_id` in the table `DumpResponse` - pub data_producer_id: ::planus::alloc::string::String, - /// The field `type` in the table `DumpResponse` - pub type_: super::data_producer::Type, - /// The field `sctp_stream_parameters` in the table `DumpResponse` - pub sctp_stream_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `label` in the table `DumpResponse` - pub label: ::planus::alloc::string::String, - /// The field `protocol` in the table `DumpResponse` - pub protocol: ::planus::alloc::string::String, - /// The field `buffered_amount_low_threshold` in the table `DumpResponse` - pub buffered_amount_low_threshold: u32, - /// The field `paused` in the table `DumpResponse` - pub paused: bool, - /// The field `data_producer_paused` in the table `DumpResponse` - pub data_producer_paused: bool, - /// The field `subchannels` in the table `DumpResponse` - pub subchannels: ::planus::alloc::vec::Vec, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_data_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: impl ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - field_sctp_stream_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_label: impl ::planus::WriteAs<::planus::Offset>, - field_protocol: impl ::planus::WriteAs<::planus::Offset>, - field_buffered_amount_low_threshold: impl ::planus::WriteAsDefault, - field_paused: impl ::planus::WriteAsDefault, - field_data_producer_paused: impl ::planus::WriteAsDefault, - field_subchannels: impl ::planus::WriteAs<::planus::Offset<[u16]>>, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_data_producer_id = field_data_producer_id.prepare(builder); - let prepared_type_ = - field_type_.prepare(builder, &super::data_producer::Type::Sctp); - let prepared_sctp_stream_parameters = - field_sctp_stream_parameters.prepare(builder); - let prepared_label = field_label.prepare(builder); - let prepared_protocol = field_protocol.prepare(builder); - let prepared_buffered_amount_low_threshold = - field_buffered_amount_low_threshold.prepare(builder, &0); - let prepared_paused = field_paused.prepare(builder, &false); - let prepared_data_producer_paused = - field_data_producer_paused.prepare(builder, &false); - let prepared_subchannels = field_subchannels.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<24> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_sctp_stream_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - table_writer.write_entry::<::planus::Offset>(4); - table_writer.write_entry::<::planus::Offset>(5); - if prepared_buffered_amount_low_threshold.is_some() { - table_writer.write_entry::(6); - } - table_writer.write_entry::<::planus::Offset<[u16]>>(9); - if prepared_type_.is_some() { - table_writer.write_entry::(2); - } - if prepared_paused.is_some() { - table_writer.write_entry::(7); - } - if prepared_data_producer_paused.is_some() { - table_writer.write_entry::(8); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_data_producer_id); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - object_writer.write::<_, _, 4>(&prepared_sctp_stream_parameters); - } - object_writer.write::<_, _, 4>(&prepared_label); - object_writer.write::<_, _, 4>(&prepared_protocol); - if let ::core::option::Option::Some( - prepared_buffered_amount_low_threshold, - ) = prepared_buffered_amount_low_threshold - { - object_writer - .write::<_, _, 4>(&prepared_buffered_amount_low_threshold); - } - object_writer.write::<_, _, 4>(&prepared_subchannels); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - if let ::core::option::Option::Some(prepared_data_producer_paused) = - prepared_data_producer_paused - { - object_writer.write::<_, _, 1>(&prepared_data_producer_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.id, - &self.data_producer_id, - self.type_, - &self.sctp_stream_parameters, - &self.label, - &self.protocol, - self.buffered_amount_low_threshold, - self.paused, - self.data_producer_paused, - &self.subchannels, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`data_producer_id` field](DumpResponse#structfield.data_producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_id(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - - /// Sets the [`type` field](DumpResponse#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.type_(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters( - self, - value: T3, - ) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters_as_null( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, ())> { - self.sctp_stream_parameters(()) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`label` field](DumpResponse#structfield.label). - #[inline] - #[allow(clippy::type_complexity)] - pub fn label(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`protocol` field](DumpResponse#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`buffered_amount_low_threshold` field](DumpResponse#structfield.buffered_amount_low_threshold). - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount_low_threshold( - self, - value: T6, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`buffered_amount_low_threshold` field](DumpResponse#structfield.buffered_amount_low_threshold) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount_low_threshold_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.buffered_amount_low_threshold(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`paused` field](DumpResponse#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T7, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_paused( - self, - value: T8, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_paused_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> - { - self.data_producer_paused(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`subchannels` field](DumpResponse#structfield.subchannels). - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels( - self, - value: T9, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAs<::planus::Offset<[u16]>>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - } - - impl - DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs<::planus::Offset>, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAs<::planus::Offset<[u16]>>, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs<::planus::Offset>, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAs<::planus::Offset<[u16]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs<::planus::Offset>, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAs<::planus::Offset<[u16]>>, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`id` field](DumpResponse#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "DumpResponse", "id") - } - - /// Getter for the [`data_producer_id` field](DumpResponse#structfield.data_producer_id). - #[inline] - pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(1, "DumpResponse", "data_producer_id") - } - - /// Getter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "DumpResponse", "type_")? - .unwrap_or(super::data_producer::Type::Sctp), - ) - } - - /// Getter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). - #[inline] - pub fn sctp_stream_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(3, "DumpResponse", "sctp_stream_parameters") - } - - /// Getter for the [`label` field](DumpResponse#structfield.label). - #[inline] - pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(4, "DumpResponse", "label") - } - - /// Getter for the [`protocol` field](DumpResponse#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(5, "DumpResponse", "protocol") - } - - /// Getter for the [`buffered_amount_low_threshold` field](DumpResponse#structfield.buffered_amount_low_threshold). - #[inline] - pub fn buffered_amount_low_threshold(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "DumpResponse", "buffered_amount_low_threshold")? - .unwrap_or(0), - ) - } - - /// Getter for the [`paused` field](DumpResponse#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(7, "DumpResponse", "paused")?.unwrap_or(false), - ) - } - - /// Getter for the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused). - #[inline] - pub fn data_producer_paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(8, "DumpResponse", "data_producer_paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`subchannels` field](DumpResponse#structfield.subchannels). - #[inline] - pub fn subchannels(&self) -> ::planus::Result<::planus::Vector<'a, u16>> { - self.0.access_required(9, "DumpResponse", "subchannels") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("id", &self.id()); - f.field("data_producer_id", &self.data_producer_id()); - f.field("type_", &self.type_()); - if let ::core::option::Option::Some(field_sctp_stream_parameters) = - self.sctp_stream_parameters().transpose() - { - f.field("sctp_stream_parameters", &field_sctp_stream_parameters); - } - f.field("label", &self.label()); - f.field("protocol", &self.protocol()); - f.field( - "buffered_amount_low_threshold", - &self.buffered_amount_low_threshold(), - ); - f.field("paused", &self.paused()); - f.field("data_producer_paused", &self.data_producer_paused()); - f.field("subchannels", &self.subchannels()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - data_producer_id: ::core::convert::TryInto::try_into( - value.data_producer_id()?, - )?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - sctp_stream_parameters: if let ::core::option::Option::Some( - sctp_stream_parameters, - ) = value.sctp_stream_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(sctp_stream_parameters)?, - )) - } else { - ::core::option::Option::None - }, - label: ::core::convert::TryInto::try_into(value.label()?)?, - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - buffered_amount_low_threshold: ::core::convert::TryInto::try_into( - value.buffered_amount_low_threshold()?, - )?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - data_producer_paused: ::core::convert::TryInto::try_into( - value.data_producer_paused()?, - )?, - subchannels: value.subchannels()?.to_vec()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/dataConsumer.fbs:28` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `timestamp` in the table `GetStatsResponse` - pub timestamp: u64, - /// The field `label` in the table `GetStatsResponse` - pub label: ::planus::alloc::string::String, - /// The field `protocol` in the table `GetStatsResponse` - pub protocol: ::planus::alloc::string::String, - /// The field `messages_sent` in the table `GetStatsResponse` - pub messages_sent: u64, - /// The field `bytes_sent` in the table `GetStatsResponse` - pub bytes_sent: u64, - /// The field `buffered_amount` in the table `GetStatsResponse` - pub buffered_amount: u32, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_timestamp: impl ::planus::WriteAsDefault, - field_label: impl ::planus::WriteAs<::planus::Offset>, - field_protocol: impl ::planus::WriteAs<::planus::Offset>, - field_messages_sent: impl ::planus::WriteAsDefault, - field_bytes_sent: impl ::planus::WriteAsDefault, - field_buffered_amount: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_label = field_label.prepare(builder); - let prepared_protocol = field_protocol.prepare(builder); - let prepared_messages_sent = field_messages_sent.prepare(builder, &0); - let prepared_bytes_sent = field_bytes_sent.prepare(builder, &0); - let prepared_buffered_amount = field_buffered_amount.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(0); - } - if prepared_messages_sent.is_some() { - table_writer.write_entry::(3); - } - if prepared_bytes_sent.is_some() { - table_writer.write_entry::(4); - } - table_writer.write_entry::<::planus::Offset>(1); - table_writer.write_entry::<::planus::Offset>(2); - if prepared_buffered_amount.is_some() { - table_writer.write_entry::(5); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_messages_sent) = - prepared_messages_sent - { - object_writer.write::<_, _, 8>(&prepared_messages_sent); - } - if let ::core::option::Option::Some(prepared_bytes_sent) = - prepared_bytes_sent - { - object_writer.write::<_, _, 8>(&prepared_bytes_sent); - } - object_writer.write::<_, _, 4>(&prepared_label); - object_writer.write::<_, _, 4>(&prepared_protocol); - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - object_writer.write::<_, _, 4>(&prepared_buffered_amount); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create( - builder, - self.timestamp, - &self.label, - &self.protocol, - self.messages_sent, - self.bytes_sent, - self.buffered_amount, - ) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - GetStatsResponseBuilder((value,)) - } - - /// Sets the [`timestamp` field](GetStatsResponse#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default( - self, - ) -> GetStatsResponseBuilder<(::planus::DefaultValue,)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Setter for the [`label` field](GetStatsResponse#structfield.label). - #[inline] - #[allow(clippy::type_complexity)] - pub fn label(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - GetStatsResponseBuilder((v0, value)) - } - } - - impl GetStatsResponseBuilder<(T0, T1)> { - /// Setter for the [`protocol` field](GetStatsResponse#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol(self, value: T2) -> GetStatsResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - GetStatsResponseBuilder((v0, v1, value)) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`messages_sent` field](GetStatsResponse#structfield.messages_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn messages_sent( - self, - value: T3, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - GetStatsResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`messages_sent` field](GetStatsResponse#structfield.messages_sent) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn messages_sent_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.messages_sent(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`bytes_sent` field](GetStatsResponse#structfield.bytes_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_sent( - self, - value: T4, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - GetStatsResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`bytes_sent` field](GetStatsResponse#structfield.bytes_sent) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_sent_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.bytes_sent(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount( - self, - value: T5, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - GetStatsResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.buffered_amount(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - GetStatsResponse::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "GetStatsResponse", "timestamp")? - .unwrap_or(0), - ) - } - - /// Getter for the [`label` field](GetStatsResponse#structfield.label). - #[inline] - pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "GetStatsResponse", "label") - } - - /// Getter for the [`protocol` field](GetStatsResponse#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "GetStatsResponse", "protocol") - } - - /// Getter for the [`messages_sent` field](GetStatsResponse#structfield.messages_sent). - #[inline] - pub fn messages_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "GetStatsResponse", "messages_sent")? - .unwrap_or(0), - ) - } - - /// Getter for the [`bytes_sent` field](GetStatsResponse#structfield.bytes_sent). - #[inline] - pub fn bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "GetStatsResponse", "bytes_sent")? - .unwrap_or(0), - ) - } - - /// Getter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). - #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "GetStatsResponse", "buffered_amount")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("timestamp", &self.timestamp()); - f.field("label", &self.label()); - f.field("protocol", &self.protocol()); - f.field("messages_sent", &self.messages_sent()); - f.field("bytes_sent", &self.bytes_sent()); - f.field("buffered_amount", &self.buffered_amount()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - label: ::core::convert::TryInto::try_into(value.label()?)?, - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - messages_sent: ::core::convert::TryInto::try_into(value.messages_sent()?)?, - bytes_sent: ::core::convert::TryInto::try_into(value.bytes_sent()?)?, - buffered_amount: ::core::convert::TryInto::try_into( - value.buffered_amount()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `SendRequest` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:37` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SendRequest { - /// The field `ppid` in the table `SendRequest` - pub ppid: u32, - /// The field `data` in the table `SendRequest` - pub data: ::planus::alloc::vec::Vec, - } - - impl SendRequest { - /// Creates a [SendRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SendRequestBuilder<()> { - SendRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ppid: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_ppid = field_ppid.prepare(builder, &0); - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_ppid.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset<[u8]>>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - object_writer.write::<_, _, 4>(&prepared_ppid); - } - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SendRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SendRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SendRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendRequest::create(builder, self.ppid, &self.data) - } - } - - /// Builder for serializing an instance of the [SendRequest] type. - /// - /// Can be created using the [SendRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SendRequestBuilder(State); - - impl SendRequestBuilder<()> { - /// Setter for the [`ppid` field](SendRequest#structfield.ppid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ppid(self, value: T0) -> SendRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SendRequestBuilder((value,)) - } - - /// Sets the [`ppid` field](SendRequest#structfield.ppid) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ppid_as_default(self) -> SendRequestBuilder<(::planus::DefaultValue,)> { - self.ppid(::planus::DefaultValue) - } - } - - impl SendRequestBuilder<(T0,)> { - /// Setter for the [`data` field](SendRequest#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> SendRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - let (v0,) = self.0; - SendRequestBuilder((v0, value)) - } - } - - impl SendRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAs<::planus::Offset> - for SendRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for SendRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAsOffset for SendRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - SendRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [SendRequest]. - #[derive(Copy, Clone)] - pub struct SendRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SendRequestRef<'a> { - /// Getter for the [`ppid` field](SendRequest#structfield.ppid). - #[inline] - pub fn ppid(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "SendRequest", "ppid")?.unwrap_or(0), - ) - } - - /// Getter for the [`data` field](SendRequest#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(1, "SendRequest", "data") - } - } - - impl<'a> ::core::fmt::Debug for SendRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SendRequestRef"); - f.field("ppid", &self.ppid()); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SendRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SendRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, - data: value.data()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SendRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SendRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SendRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SendRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SendRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SendRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `SetSubchannelsRequest` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `SetSubchannelsRequest` in the file `../worker/fbs/dataConsumer.fbs:42` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetSubchannelsRequest { - /// The field `subchannels` in the table `SetSubchannelsRequest` - pub subchannels: ::planus::alloc::vec::Vec, - } - - impl SetSubchannelsRequest { - /// Creates a [SetSubchannelsRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetSubchannelsRequestBuilder<()> { - SetSubchannelsRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_subchannels: impl ::planus::WriteAs<::planus::Offset<[u16]>>, - ) -> ::planus::Offset { - let prepared_subchannels = field_subchannels.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u16]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_subchannels); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SetSubchannelsRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SetSubchannelsRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetSubchannelsRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetSubchannelsRequest::create(builder, &self.subchannels) - } - } - - /// Builder for serializing an instance of the [SetSubchannelsRequest] type. - /// - /// Can be created using the [SetSubchannelsRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetSubchannelsRequestBuilder(State); - - impl SetSubchannelsRequestBuilder<()> { - /// Setter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels(self, value: T0) -> SetSubchannelsRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u16]>>, - { - SetSubchannelsRequestBuilder((value,)) - } - } - - impl SetSubchannelsRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetSubchannelsRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for SetSubchannelsRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SetSubchannelsRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for SetSubchannelsRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetSubchannelsRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetSubchannelsRequest]. - #[derive(Copy, Clone)] - pub struct SetSubchannelsRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetSubchannelsRequestRef<'a> { - /// Getter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). - #[inline] - pub fn subchannels(&self) -> ::planus::Result<::planus::Vector<'a, u16>> { - self.0 - .access_required(0, "SetSubchannelsRequest", "subchannels") - } - } - - impl<'a> ::core::fmt::Debug for SetSubchannelsRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetSubchannelsRequestRef"); - f.field("subchannels", &self.subchannels()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SetSubchannelsRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetSubchannelsRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - subchannels: value.subchannels()?.to_vec()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetSubchannelsRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetSubchannelsRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetSubchannelsRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SetSubchannelsRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetSubchannelsRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetSubchannelsRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SetSubchannelsResponse` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `SetSubchannelsResponse` in the file `../worker/fbs/dataConsumer.fbs:46` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetSubchannelsResponse { - /// The field `subchannels` in the table `SetSubchannelsResponse` - pub subchannels: ::planus::alloc::vec::Vec, - } - - impl SetSubchannelsResponse { - /// Creates a [SetSubchannelsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetSubchannelsResponseBuilder<()> { - SetSubchannelsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_subchannels: impl ::planus::WriteAs<::planus::Offset<[u16]>>, - ) -> ::planus::Offset { - let prepared_subchannels = field_subchannels.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u16]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_subchannels); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SetSubchannelsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetSubchannelsResponse - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetSubchannelsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetSubchannelsResponse::create(builder, &self.subchannels) - } - } - - /// Builder for serializing an instance of the [SetSubchannelsResponse] type. - /// - /// Can be created using the [SetSubchannelsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetSubchannelsResponseBuilder(State); - - impl SetSubchannelsResponseBuilder<()> { - /// Setter for the [`subchannels` field](SetSubchannelsResponse#structfield.subchannels). - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels(self, value: T0) -> SetSubchannelsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u16]>>, - { - SetSubchannelsResponseBuilder((value,)) - } - } - - impl SetSubchannelsResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetSubchannelsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for SetSubchannelsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SetSubchannelsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for SetSubchannelsResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetSubchannelsResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [SetSubchannelsResponse]. - #[derive(Copy, Clone)] - pub struct SetSubchannelsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetSubchannelsResponseRef<'a> { - /// Getter for the [`subchannels` field](SetSubchannelsResponse#structfield.subchannels). - #[inline] - pub fn subchannels(&self) -> ::planus::Result<::planus::Vector<'a, u16>> { - self.0 - .access_required(0, "SetSubchannelsResponse", "subchannels") - } - } - - impl<'a> ::core::fmt::Debug for SetSubchannelsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetSubchannelsResponseRef"); - f.field("subchannels", &self.subchannels()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SetSubchannelsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetSubchannelsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - subchannels: value.subchannels()?.to_vec()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetSubchannelsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetSubchannelsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetSubchannelsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SetSubchannelsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetSubchannelsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetSubchannelsResponseRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `BufferedAmountLowNotification` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `BufferedAmountLowNotification` in the file `../worker/fbs/dataConsumer.fbs:52` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct BufferedAmountLowNotification { - /// The field `buffered_amount` in the table `BufferedAmountLowNotification` - pub buffered_amount: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for BufferedAmountLowNotification { - fn default() -> Self { - Self { buffered_amount: 0 } - } - } - - impl BufferedAmountLowNotification { - /// Creates a [BufferedAmountLowNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BufferedAmountLowNotificationBuilder<()> { - BufferedAmountLowNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_buffered_amount: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_buffered_amount = field_buffered_amount.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_buffered_amount.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - object_writer.write::<_, _, 4>(&prepared_buffered_amount); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for BufferedAmountLowNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for BufferedAmountLowNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for BufferedAmountLowNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - BufferedAmountLowNotification::create(builder, self.buffered_amount) - } - } - - /// Builder for serializing an instance of the [BufferedAmountLowNotification] type. - /// - /// Can be created using the [BufferedAmountLowNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BufferedAmountLowNotificationBuilder(State); - - impl BufferedAmountLowNotificationBuilder<()> { - /// Setter for the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount). - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount( - self, - value: T0, - ) -> BufferedAmountLowNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - BufferedAmountLowNotificationBuilder((value,)) - } - - /// Sets the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount_as_default( - self, - ) -> BufferedAmountLowNotificationBuilder<(::planus::DefaultValue,)> - { - self.buffered_amount(::planus::DefaultValue) - } - } - - impl BufferedAmountLowNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BufferedAmountLowNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for BufferedAmountLowNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for BufferedAmountLowNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for BufferedAmountLowNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - BufferedAmountLowNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [BufferedAmountLowNotification]. - #[derive(Copy, Clone)] - pub struct BufferedAmountLowNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BufferedAmountLowNotificationRef<'a> { - /// Getter for the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount). - #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "BufferedAmountLowNotification", "buffered_amount")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for BufferedAmountLowNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BufferedAmountLowNotificationRef"); - f.field("buffered_amount", &self.buffered_amount()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for BufferedAmountLowNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: BufferedAmountLowNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - buffered_amount: ::core::convert::TryInto::try_into( - value.buffered_amount()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for BufferedAmountLowNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for BufferedAmountLowNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[BufferedAmountLowNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for BufferedAmountLowNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for BufferedAmountLowNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[BufferedAmountLowNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `MessageNotification` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:56` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct MessageNotification { - /// The field `ppid` in the table `MessageNotification` - pub ppid: u32, - /// The field `data` in the table `MessageNotification` - pub data: ::planus::alloc::vec::Vec, - } - - impl MessageNotification { - /// Creates a [MessageNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> MessageNotificationBuilder<()> { - MessageNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ppid: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_ppid = field_ppid.prepare(builder, &0); - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_ppid.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset<[u8]>>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - object_writer.write::<_, _, 4>(&prepared_ppid); - } - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for MessageNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for MessageNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for MessageNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - MessageNotification::create(builder, self.ppid, &self.data) - } - } - - /// Builder for serializing an instance of the [MessageNotification] type. - /// - /// Can be created using the [MessageNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct MessageNotificationBuilder(State); - - impl MessageNotificationBuilder<()> { - /// Setter for the [`ppid` field](MessageNotification#structfield.ppid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ppid(self, value: T0) -> MessageNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - MessageNotificationBuilder((value,)) - } - - /// Sets the [`ppid` field](MessageNotification#structfield.ppid) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ppid_as_default( - self, - ) -> MessageNotificationBuilder<(::planus::DefaultValue,)> { - self.ppid(::planus::DefaultValue) - } - } - - impl MessageNotificationBuilder<(T0,)> { - /// Setter for the [`data` field](MessageNotification#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> MessageNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - let (v0,) = self.0; - MessageNotificationBuilder((v0, value)) - } - } - - impl MessageNotificationBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [MessageNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAs<::planus::Offset> - for MessageNotificationBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for MessageNotificationBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - > ::planus::WriteAsOffset - for MessageNotificationBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - MessageNotification::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [MessageNotification]. - #[derive(Copy, Clone)] - pub struct MessageNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> MessageNotificationRef<'a> { - /// Getter for the [`ppid` field](MessageNotification#structfield.ppid). - #[inline] - pub fn ppid(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "MessageNotification", "ppid")? - .unwrap_or(0), - ) - } - - /// Getter for the [`data` field](MessageNotification#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(1, "MessageNotification", "data") - } - } - - impl<'a> ::core::fmt::Debug for MessageNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("MessageNotificationRef"); - f.field("ppid", &self.ppid()); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for MessageNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: MessageNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, - data: value.data()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for MessageNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for MessageNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[MessageNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for MessageNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for MessageNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[MessageNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/dataProducer.fbs` - pub mod data_producer { - /// The enum `Type` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Enum `Type` in the file `../worker/fbs/dataProducer.fbs:5` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum Type { - /// The variant `SCTP` in the enum `Type` - Sctp = 0, - - /// The variant `DIRECT` in the enum `Type` - Direct = 1, - } - - impl Type { - /// Array containing all valid variants of Type - pub const ENUM_VALUES: [Self; 2] = [Self::Sctp, Self::Direct]; - } - - impl ::core::convert::TryFrom for Type { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(Type::Sctp), - 1 => ::core::result::Result::Ok(Type::Direct), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: Type) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for Type { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for Type { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for Type { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { - *self - } - } - - impl ::planus::WriteAsDefault for Type { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &Type, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for Type { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for Type { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for Type { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "Type", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for Type { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `DumpResponse` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/dataProducer.fbs:10` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `id` in the table `DumpResponse` - pub id: ::planus::alloc::string::String, - /// The field `type` in the table `DumpResponse` - pub type_: self::Type, - /// The field `sctp_stream_parameters` in the table `DumpResponse` - pub sctp_stream_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `label` in the table `DumpResponse` - pub label: ::planus::alloc::string::String, - /// The field `protocol` in the table `DumpResponse` - pub protocol: ::planus::alloc::string::String, - /// The field `paused` in the table `DumpResponse` - pub paused: bool, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: impl ::planus::WriteAsDefault, - field_sctp_stream_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_label: impl ::planus::WriteAs<::planus::Offset>, - field_protocol: impl ::planus::WriteAs<::planus::Offset>, - field_paused: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_type_ = field_type_.prepare(builder, &self::Type::Sctp); - let prepared_sctp_stream_parameters = - field_sctp_stream_parameters.prepare(builder); - let prepared_label = field_label.prepare(builder); - let prepared_protocol = field_protocol.prepare(builder); - let prepared_paused = field_paused.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_sctp_stream_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - table_writer.write_entry::<::planus::Offset>(3); - table_writer.write_entry::<::planus::Offset>(4); - if prepared_type_.is_some() { - table_writer.write_entry::(1); - } - if prepared_paused.is_some() { - table_writer.write_entry::(5); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - object_writer.write::<_, _, 4>(&prepared_sctp_stream_parameters); - } - object_writer.write::<_, _, 4>(&prepared_label); - object_writer.write::<_, _, 4>(&prepared_protocol); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.id, - self.type_, - &self.sctp_stream_parameters, - &self.label, - &self.protocol, - self.paused, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - - /// Sets the [`type` field](DumpResponse#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default(self) -> DumpResponseBuilder<(T0, ::planus::DefaultValue)> { - self.type_(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters( - self, - value: T2, - ) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - - /// Sets the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters_as_null(self) -> DumpResponseBuilder<(T0, T1, ())> { - self.sctp_stream_parameters(()) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`label` field](DumpResponse#structfield.label). - #[inline] - #[allow(clippy::type_complexity)] - pub fn label(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`protocol` field](DumpResponse#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`paused` field](DumpResponse#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused(self, value: T5) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`id` field](DumpResponse#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "DumpResponse", "id") - } - - /// Getter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "DumpResponse", "type_")? - .unwrap_or(self::Type::Sctp), - ) - } - - /// Getter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). - #[inline] - pub fn sctp_stream_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(2, "DumpResponse", "sctp_stream_parameters") - } - - /// Getter for the [`label` field](DumpResponse#structfield.label). - #[inline] - pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(3, "DumpResponse", "label") - } - - /// Getter for the [`protocol` field](DumpResponse#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(4, "DumpResponse", "protocol") - } - - /// Getter for the [`paused` field](DumpResponse#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(5, "DumpResponse", "paused")?.unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("id", &self.id()); - f.field("type_", &self.type_()); - if let ::core::option::Option::Some(field_sctp_stream_parameters) = - self.sctp_stream_parameters().transpose() - { - f.field("sctp_stream_parameters", &field_sctp_stream_parameters); - } - f.field("label", &self.label()); - f.field("protocol", &self.protocol()); - f.field("paused", &self.paused()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - sctp_stream_parameters: if let ::core::option::Option::Some( - sctp_stream_parameters, - ) = value.sctp_stream_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(sctp_stream_parameters)?, - )) - } else { - ::core::option::Option::None - }, - label: ::core::convert::TryInto::try_into(value.label()?)?, - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/dataProducer.fbs:19` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `timestamp` in the table `GetStatsResponse` - pub timestamp: u64, - /// The field `label` in the table `GetStatsResponse` - pub label: ::planus::alloc::string::String, - /// The field `protocol` in the table `GetStatsResponse` - pub protocol: ::planus::alloc::string::String, - /// The field `messages_received` in the table `GetStatsResponse` - pub messages_received: u64, - /// The field `bytes_received` in the table `GetStatsResponse` - pub bytes_received: u64, - /// The field `buffered_amount` in the table `GetStatsResponse` - pub buffered_amount: u32, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_timestamp: impl ::planus::WriteAsDefault, - field_label: impl ::planus::WriteAs<::planus::Offset>, - field_protocol: impl ::planus::WriteAs<::planus::Offset>, - field_messages_received: impl ::planus::WriteAsDefault, - field_bytes_received: impl ::planus::WriteAsDefault, - field_buffered_amount: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_label = field_label.prepare(builder); - let prepared_protocol = field_protocol.prepare(builder); - let prepared_messages_received = field_messages_received.prepare(builder, &0); - let prepared_bytes_received = field_bytes_received.prepare(builder, &0); - let prepared_buffered_amount = field_buffered_amount.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(0); - } - if prepared_messages_received.is_some() { - table_writer.write_entry::(3); - } - if prepared_bytes_received.is_some() { - table_writer.write_entry::(4); - } - table_writer.write_entry::<::planus::Offset>(1); - table_writer.write_entry::<::planus::Offset>(2); - if prepared_buffered_amount.is_some() { - table_writer.write_entry::(5); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_messages_received) = - prepared_messages_received - { - object_writer.write::<_, _, 8>(&prepared_messages_received); - } - if let ::core::option::Option::Some(prepared_bytes_received) = - prepared_bytes_received - { - object_writer.write::<_, _, 8>(&prepared_bytes_received); - } - object_writer.write::<_, _, 4>(&prepared_label); - object_writer.write::<_, _, 4>(&prepared_protocol); - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - object_writer.write::<_, _, 4>(&prepared_buffered_amount); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create( - builder, - self.timestamp, - &self.label, - &self.protocol, - self.messages_received, - self.bytes_received, - self.buffered_amount, - ) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - GetStatsResponseBuilder((value,)) - } - - /// Sets the [`timestamp` field](GetStatsResponse#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default( - self, - ) -> GetStatsResponseBuilder<(::planus::DefaultValue,)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Setter for the [`label` field](GetStatsResponse#structfield.label). - #[inline] - #[allow(clippy::type_complexity)] - pub fn label(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - GetStatsResponseBuilder((v0, value)) - } - } - - impl GetStatsResponseBuilder<(T0, T1)> { - /// Setter for the [`protocol` field](GetStatsResponse#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol(self, value: T2) -> GetStatsResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - GetStatsResponseBuilder((v0, v1, value)) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`messages_received` field](GetStatsResponse#structfield.messages_received). - #[inline] - #[allow(clippy::type_complexity)] - pub fn messages_received( - self, - value: T3, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - GetStatsResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`messages_received` field](GetStatsResponse#structfield.messages_received) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn messages_received_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.messages_received(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`bytes_received` field](GetStatsResponse#structfield.bytes_received). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_received( - self, - value: T4, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - GetStatsResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`bytes_received` field](GetStatsResponse#structfield.bytes_received) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_received_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.bytes_received(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount( - self, - value: T5, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - GetStatsResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn buffered_amount_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.buffered_amount(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - GetStatsResponse::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "GetStatsResponse", "timestamp")? - .unwrap_or(0), - ) - } - - /// Getter for the [`label` field](GetStatsResponse#structfield.label). - #[inline] - pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "GetStatsResponse", "label") - } - - /// Getter for the [`protocol` field](GetStatsResponse#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "GetStatsResponse", "protocol") - } - - /// Getter for the [`messages_received` field](GetStatsResponse#structfield.messages_received). - #[inline] - pub fn messages_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "GetStatsResponse", "messages_received")? - .unwrap_or(0), - ) - } - - /// Getter for the [`bytes_received` field](GetStatsResponse#structfield.bytes_received). - #[inline] - pub fn bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "GetStatsResponse", "bytes_received")? - .unwrap_or(0), - ) - } - - /// Getter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). - #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "GetStatsResponse", "buffered_amount")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("timestamp", &self.timestamp()); - f.field("label", &self.label()); - f.field("protocol", &self.protocol()); - f.field("messages_received", &self.messages_received()); - f.field("bytes_received", &self.bytes_received()); - f.field("buffered_amount", &self.buffered_amount()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - label: ::core::convert::TryInto::try_into(value.label()?)?, - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - messages_received: ::core::convert::TryInto::try_into( - value.messages_received()?, - )?, - bytes_received: ::core::convert::TryInto::try_into( - value.bytes_received()?, - )?, - buffered_amount: ::core::convert::TryInto::try_into( - value.buffered_amount()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `SendNotification` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Table `SendNotification` in the file `../worker/fbs/dataProducer.fbs:28` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SendNotification { - /// The field `ppid` in the table `SendNotification` - pub ppid: u32, - /// The field `data` in the table `SendNotification` - pub data: ::planus::alloc::vec::Vec, - /// The field `subchannels` in the table `SendNotification` - pub subchannels: ::core::option::Option<::planus::alloc::vec::Vec>, - /// The field `required_subchannel` in the table `SendNotification` - pub required_subchannel: ::core::option::Option, - } - - impl SendNotification { - /// Creates a [SendNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SendNotificationBuilder<()> { - SendNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ppid: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - field_required_subchannel: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_ppid = field_ppid.prepare(builder, &0); - let prepared_data = field_data.prepare(builder); - let prepared_subchannels = field_subchannels.prepare(builder); - let prepared_required_subchannel = field_required_subchannel.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_ppid.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset<[u8]>>(1); - if prepared_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(2); - } - if prepared_required_subchannel.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - object_writer.write::<_, _, 4>(&prepared_ppid); - } - object_writer.write::<_, _, 4>(&prepared_data); - if let ::core::option::Option::Some(prepared_subchannels) = - prepared_subchannels - { - object_writer.write::<_, _, 4>(&prepared_subchannels); - } - if let ::core::option::Option::Some(prepared_required_subchannel) = - prepared_required_subchannel - { - object_writer.write::<_, _, 2>(&prepared_required_subchannel); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SendNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SendNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SendNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendNotification::create( - builder, - self.ppid, - &self.data, - &self.subchannels, - self.required_subchannel, - ) - } - } - - /// Builder for serializing an instance of the [SendNotification] type. - /// - /// Can be created using the [SendNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SendNotificationBuilder(State); - - impl SendNotificationBuilder<()> { - /// Setter for the [`ppid` field](SendNotification#structfield.ppid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ppid(self, value: T0) -> SendNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SendNotificationBuilder((value,)) - } - - /// Sets the [`ppid` field](SendNotification#structfield.ppid) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ppid_as_default(self) -> SendNotificationBuilder<(::planus::DefaultValue,)> { - self.ppid(::planus::DefaultValue) - } - } - - impl SendNotificationBuilder<(T0,)> { - /// Setter for the [`data` field](SendNotification#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> SendNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - let (v0,) = self.0; - SendNotificationBuilder((v0, value)) - } - } - - impl SendNotificationBuilder<(T0, T1)> { - /// Setter for the [`subchannels` field](SendNotification#structfield.subchannels). - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels(self, value: T2) -> SendNotificationBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - { - let (v0, v1) = self.0; - SendNotificationBuilder((v0, v1, value)) - } - - /// Sets the [`subchannels` field](SendNotification#structfield.subchannels) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels_as_null(self) -> SendNotificationBuilder<(T0, T1, ())> { - self.subchannels(()) - } - } - - impl SendNotificationBuilder<(T0, T1, T2)> { - /// Setter for the [`required_subchannel` field](SendNotification#structfield.required_subchannel). - #[inline] - #[allow(clippy::type_complexity)] - pub fn required_subchannel( - self, - value: T3, - ) -> SendNotificationBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional, - { - let (v0, v1, v2) = self.0; - SendNotificationBuilder((v0, v1, v2, value)) - } - - /// Sets the [`required_subchannel` field](SendNotification#structfield.required_subchannel) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn required_subchannel_as_null( - self, - ) -> SendNotificationBuilder<(T0, T1, T2, ())> { - self.required_subchannel(()) - } - } - - impl SendNotificationBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for SendNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for SendNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[u8]>>, - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for SendNotificationBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - SendNotification::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [SendNotification]. - #[derive(Copy, Clone)] - pub struct SendNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SendNotificationRef<'a> { - /// Getter for the [`ppid` field](SendNotification#structfield.ppid). - #[inline] - pub fn ppid(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "SendNotification", "ppid")?.unwrap_or(0), - ) - } - - /// Getter for the [`data` field](SendNotification#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(1, "SendNotification", "data") - } - - /// Getter for the [`subchannels` field](SendNotification#structfield.subchannels). - #[inline] - pub fn subchannels( - &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> - { - self.0.access(2, "SendNotification", "subchannels") - } - - /// Getter for the [`required_subchannel` field](SendNotification#structfield.required_subchannel). - #[inline] - pub fn required_subchannel(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(3, "SendNotification", "required_subchannel") - } - } - - impl<'a> ::core::fmt::Debug for SendNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SendNotificationRef"); - f.field("ppid", &self.ppid()); - f.field("data", &self.data()); - if let ::core::option::Option::Some(field_subchannels) = - self.subchannels().transpose() - { - f.field("subchannels", &field_subchannels); - } - if let ::core::option::Option::Some(field_required_subchannel) = - self.required_subchannel().transpose() - { - f.field("required_subchannel", &field_required_subchannel); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SendNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SendNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, - data: value.data()?.to_vec(), - subchannels: if let ::core::option::Option::Some(subchannels) = - value.subchannels()? - { - ::core::option::Option::Some(subchannels.to_vec()?) - } else { - ::core::option::Option::None - }, - required_subchannel: if let ::core::option::Option::Some( - required_subchannel, - ) = value.required_subchannel()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - required_subchannel, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SendNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SendNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SendNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SendNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SendNotificationRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.SctpParameters` - /// - /// Generated from these locations: - /// * File `../worker/fbs/sctpParameters.fbs` - pub mod sctp_parameters { - /// The table `NumSctpStreams` in the namespace `FBS.SctpParameters` - /// - /// Generated from these locations: - /// * Table `NumSctpStreams` in the file `../worker/fbs/sctpParameters.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct NumSctpStreams { - /// The field `os` in the table `NumSctpStreams` - pub os: u16, - /// The field `mis` in the table `NumSctpStreams` - pub mis: u16, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for NumSctpStreams { - fn default() -> Self { - Self { - os: 1024, - mis: 1024, - } - } - } - - impl NumSctpStreams { - /// Creates a [NumSctpStreamsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> NumSctpStreamsBuilder<()> { - NumSctpStreamsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_os: impl ::planus::WriteAsDefault, - field_mis: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_os = field_os.prepare(builder, &1024); - let prepared_mis = field_mis.prepare(builder, &1024); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_os.is_some() { - table_writer.write_entry::(0); - } - if prepared_mis.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_os) = prepared_os { - object_writer.write::<_, _, 2>(&prepared_os); - } - if let ::core::option::Option::Some(prepared_mis) = prepared_mis { - object_writer.write::<_, _, 2>(&prepared_mis); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for NumSctpStreams { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for NumSctpStreams { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for NumSctpStreams { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - NumSctpStreams::create(builder, self.os, self.mis) - } - } - - /// Builder for serializing an instance of the [NumSctpStreams] type. - /// - /// Can be created using the [NumSctpStreams::builder] method. - #[derive(Debug)] - #[must_use] - pub struct NumSctpStreamsBuilder(State); - - impl NumSctpStreamsBuilder<()> { - /// Setter for the [`os` field](NumSctpStreams#structfield.os). - #[inline] - #[allow(clippy::type_complexity)] - pub fn os(self, value: T0) -> NumSctpStreamsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - NumSctpStreamsBuilder((value,)) - } - - /// Sets the [`os` field](NumSctpStreams#structfield.os) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn os_as_default(self) -> NumSctpStreamsBuilder<(::planus::DefaultValue,)> { - self.os(::planus::DefaultValue) - } - } - - impl NumSctpStreamsBuilder<(T0,)> { - /// Setter for the [`mis` field](NumSctpStreams#structfield.mis). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mis(self, value: T1) -> NumSctpStreamsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - NumSctpStreamsBuilder((v0, value)) - } - - /// Sets the [`mis` field](NumSctpStreams#structfield.mis) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mis_as_default(self) -> NumSctpStreamsBuilder<(T0, ::planus::DefaultValue)> { - self.mis(::planus::DefaultValue) - } - } - - impl NumSctpStreamsBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [NumSctpStreams]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for NumSctpStreamsBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for NumSctpStreamsBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for NumSctpStreamsBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - NumSctpStreams::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [NumSctpStreams]. - #[derive(Copy, Clone)] - pub struct NumSctpStreamsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> NumSctpStreamsRef<'a> { - /// Getter for the [`os` field](NumSctpStreams#structfield.os). - #[inline] - pub fn os(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "NumSctpStreams", "os")?.unwrap_or(1024), - ) - } - - /// Getter for the [`mis` field](NumSctpStreams#structfield.mis). - #[inline] - pub fn mis(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "NumSctpStreams", "mis")?.unwrap_or(1024), - ) - } - } - - impl<'a> ::core::fmt::Debug for NumSctpStreamsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("NumSctpStreamsRef"); - f.field("os", &self.os()); - f.field("mis", &self.mis()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for NumSctpStreams { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: NumSctpStreamsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - os: ::core::convert::TryInto::try_into(value.os()?)?, - mis: ::core::convert::TryInto::try_into(value.mis()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for NumSctpStreamsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for NumSctpStreamsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[NumSctpStreamsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for NumSctpStreams { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for NumSctpStreamsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[NumSctpStreamsRef]", "read_as_root", 0) - }) - } - } - - /// The table `SctpParameters` in the namespace `FBS.SctpParameters` - /// - /// Generated from these locations: - /// * Table `SctpParameters` in the file `../worker/fbs/sctpParameters.fbs:8` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SctpParameters { - /// The field `port` in the table `SctpParameters` - pub port: u16, - /// The field `os` in the table `SctpParameters` - pub os: u16, - /// The field `mis` in the table `SctpParameters` - pub mis: u16, - /// The field `max_message_size` in the table `SctpParameters` - pub max_message_size: u32, - /// The field `send_buffer_size` in the table `SctpParameters` - pub send_buffer_size: u32, - /// The field `sctp_buffered_amount` in the table `SctpParameters` - pub sctp_buffered_amount: u32, - /// The field `is_data_channel` in the table `SctpParameters` - pub is_data_channel: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SctpParameters { - fn default() -> Self { - Self { - port: 5000, - os: 0, - mis: 0, - max_message_size: 0, - send_buffer_size: 0, - sctp_buffered_amount: 0, - is_data_channel: false, - } - } - } - - impl SctpParameters { - /// Creates a [SctpParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SctpParametersBuilder<()> { - SctpParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_port: impl ::planus::WriteAsDefault, - field_os: impl ::planus::WriteAsDefault, - field_mis: impl ::planus::WriteAsDefault, - field_max_message_size: impl ::planus::WriteAsDefault, - field_send_buffer_size: impl ::planus::WriteAsDefault, - field_sctp_buffered_amount: impl ::planus::WriteAsDefault, - field_is_data_channel: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_port = field_port.prepare(builder, &5000); - let prepared_os = field_os.prepare(builder, &0); - let prepared_mis = field_mis.prepare(builder, &0); - let prepared_max_message_size = field_max_message_size.prepare(builder, &0); - let prepared_send_buffer_size = field_send_buffer_size.prepare(builder, &0); - let prepared_sctp_buffered_amount = - field_sctp_buffered_amount.prepare(builder, &0); - let prepared_is_data_channel = field_is_data_channel.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<18> = - ::core::default::Default::default(); - if prepared_max_message_size.is_some() { - table_writer.write_entry::(3); - } - if prepared_send_buffer_size.is_some() { - table_writer.write_entry::(4); - } - if prepared_sctp_buffered_amount.is_some() { - table_writer.write_entry::(5); - } - if prepared_port.is_some() { - table_writer.write_entry::(0); - } - if prepared_os.is_some() { - table_writer.write_entry::(1); - } - if prepared_mis.is_some() { - table_writer.write_entry::(2); - } - if prepared_is_data_channel.is_some() { - table_writer.write_entry::(6); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_max_message_size) = - prepared_max_message_size - { - object_writer.write::<_, _, 4>(&prepared_max_message_size); - } - if let ::core::option::Option::Some(prepared_send_buffer_size) = - prepared_send_buffer_size - { - object_writer.write::<_, _, 4>(&prepared_send_buffer_size); - } - if let ::core::option::Option::Some(prepared_sctp_buffered_amount) = - prepared_sctp_buffered_amount - { - object_writer.write::<_, _, 4>(&prepared_sctp_buffered_amount); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - object_writer.write::<_, _, 2>(&prepared_port); - } - if let ::core::option::Option::Some(prepared_os) = prepared_os { - object_writer.write::<_, _, 2>(&prepared_os); - } - if let ::core::option::Option::Some(prepared_mis) = prepared_mis { - object_writer.write::<_, _, 2>(&prepared_mis); - } - if let ::core::option::Option::Some(prepared_is_data_channel) = - prepared_is_data_channel - { - object_writer.write::<_, _, 1>(&prepared_is_data_channel); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SctpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SctpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SctpParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SctpParameters::create( - builder, - self.port, - self.os, - self.mis, - self.max_message_size, - self.send_buffer_size, - self.sctp_buffered_amount, - self.is_data_channel, - ) - } - } - - /// Builder for serializing an instance of the [SctpParameters] type. - /// - /// Can be created using the [SctpParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SctpParametersBuilder(State); - - impl SctpParametersBuilder<()> { - /// Setter for the [`port` field](SctpParameters#structfield.port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn port(self, value: T0) -> SctpParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SctpParametersBuilder((value,)) - } - - /// Sets the [`port` field](SctpParameters#structfield.port) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn port_as_default(self) -> SctpParametersBuilder<(::planus::DefaultValue,)> { - self.port(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0,)> { - /// Setter for the [`os` field](SctpParameters#structfield.os). - #[inline] - #[allow(clippy::type_complexity)] - pub fn os(self, value: T1) -> SctpParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - SctpParametersBuilder((v0, value)) - } - - /// Sets the [`os` field](SctpParameters#structfield.os) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn os_as_default(self) -> SctpParametersBuilder<(T0, ::planus::DefaultValue)> { - self.os(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0, T1)> { - /// Setter for the [`mis` field](SctpParameters#structfield.mis). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mis(self, value: T2) -> SctpParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - SctpParametersBuilder((v0, v1, value)) - } - - /// Sets the [`mis` field](SctpParameters#structfield.mis) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mis_as_default( - self, - ) -> SctpParametersBuilder<(T0, T1, ::planus::DefaultValue)> { - self.mis(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`max_message_size` field](SctpParameters#structfield.max_message_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_message_size( - self, - value: T3, - ) -> SctpParametersBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - SctpParametersBuilder((v0, v1, v2, value)) - } - - /// Sets the [`max_message_size` field](SctpParameters#structfield.max_message_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_message_size_as_default( - self, - ) -> SctpParametersBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.max_message_size(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`send_buffer_size` field](SctpParameters#structfield.send_buffer_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn send_buffer_size( - self, - value: T4, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - SctpParametersBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`send_buffer_size` field](SctpParameters#structfield.send_buffer_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn send_buffer_size_as_default( - self, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.send_buffer_size(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`sctp_buffered_amount` field](SctpParameters#structfield.sctp_buffered_amount). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_buffered_amount( - self, - value: T5, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - SctpParametersBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`sctp_buffered_amount` field](SctpParameters#structfield.sctp_buffered_amount) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_buffered_amount_as_default( - self, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.sctp_buffered_amount(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`is_data_channel` field](SctpParameters#structfield.is_data_channel). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_data_channel( - self, - value: T6, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - SctpParametersBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`is_data_channel` field](SctpParameters#structfield.is_data_channel) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_data_channel_as_default( - self, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.is_data_channel(::planus::DefaultValue) - } - } - - impl SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SctpParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6) = &self.0; - SctpParameters::create(builder, v0, v1, v2, v3, v4, v5, v6) - } - } - - /// Reference to a deserialized [SctpParameters]. - #[derive(Copy, Clone)] - pub struct SctpParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SctpParametersRef<'a> { - /// Getter for the [`port` field](SctpParameters#structfield.port). - #[inline] - pub fn port(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "SctpParameters", "port")?.unwrap_or(5000), - ) - } - - /// Getter for the [`os` field](SctpParameters#structfield.os). - #[inline] - pub fn os(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "SctpParameters", "os")?.unwrap_or(0), - ) - } - - /// Getter for the [`mis` field](SctpParameters#structfield.mis). - #[inline] - pub fn mis(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(2, "SctpParameters", "mis")?.unwrap_or(0), - ) - } - - /// Getter for the [`max_message_size` field](SctpParameters#structfield.max_message_size). - #[inline] - pub fn max_message_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "SctpParameters", "max_message_size")? - .unwrap_or(0), - ) - } - - /// Getter for the [`send_buffer_size` field](SctpParameters#structfield.send_buffer_size). - #[inline] - pub fn send_buffer_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "SctpParameters", "send_buffer_size")? - .unwrap_or(0), - ) - } - - /// Getter for the [`sctp_buffered_amount` field](SctpParameters#structfield.sctp_buffered_amount). - #[inline] - pub fn sctp_buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "SctpParameters", "sctp_buffered_amount")? - .unwrap_or(0), - ) - } - - /// Getter for the [`is_data_channel` field](SctpParameters#structfield.is_data_channel). - #[inline] - pub fn is_data_channel(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "SctpParameters", "is_data_channel")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for SctpParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SctpParametersRef"); - f.field("port", &self.port()); - f.field("os", &self.os()); - f.field("mis", &self.mis()); - f.field("max_message_size", &self.max_message_size()); - f.field("send_buffer_size", &self.send_buffer_size()); - f.field("sctp_buffered_amount", &self.sctp_buffered_amount()); - f.field("is_data_channel", &self.is_data_channel()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SctpParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SctpParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - port: ::core::convert::TryInto::try_into(value.port()?)?, - os: ::core::convert::TryInto::try_into(value.os()?)?, - mis: ::core::convert::TryInto::try_into(value.mis()?)?, - max_message_size: ::core::convert::TryInto::try_into( - value.max_message_size()?, - )?, - send_buffer_size: ::core::convert::TryInto::try_into( - value.send_buffer_size()?, - )?, - sctp_buffered_amount: ::core::convert::TryInto::try_into( - value.sctp_buffered_amount()?, - )?, - is_data_channel: ::core::convert::TryInto::try_into( - value.is_data_channel()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SctpParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SctpParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SctpParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SctpParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SctpParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SctpParametersRef]", "read_as_root", 0) - }) - } - } - - /// The table `SctpStreamParameters` in the namespace `FBS.SctpParameters` - /// - /// Generated from these locations: - /// * Table `SctpStreamParameters` in the file `../worker/fbs/sctpParameters.fbs:19` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SctpStreamParameters { - /// The field `stream_id` in the table `SctpStreamParameters` - pub stream_id: u16, - /// The field `ordered` in the table `SctpStreamParameters` - pub ordered: ::core::option::Option, - /// The field `max_packet_life_time` in the table `SctpStreamParameters` - pub max_packet_life_time: ::core::option::Option, - /// The field `max_retransmits` in the table `SctpStreamParameters` - pub max_retransmits: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SctpStreamParameters { - fn default() -> Self { - Self { - stream_id: 0, - ordered: ::core::default::Default::default(), - max_packet_life_time: ::core::default::Default::default(), - max_retransmits: ::core::default::Default::default(), - } - } - } - - impl SctpStreamParameters { - /// Creates a [SctpStreamParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SctpStreamParametersBuilder<()> { - SctpStreamParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_stream_id: impl ::planus::WriteAsDefault, - field_ordered: impl ::planus::WriteAsOptional, - field_max_packet_life_time: impl ::planus::WriteAsOptional, - field_max_retransmits: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_stream_id = field_stream_id.prepare(builder, &0); - let prepared_ordered = field_ordered.prepare(builder); - let prepared_max_packet_life_time = field_max_packet_life_time.prepare(builder); - let prepared_max_retransmits = field_max_retransmits.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_stream_id.is_some() { - table_writer.write_entry::(0); - } - if prepared_max_packet_life_time.is_some() { - table_writer.write_entry::(2); - } - if prepared_max_retransmits.is_some() { - table_writer.write_entry::(3); - } - if prepared_ordered.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_stream_id) = - prepared_stream_id - { - object_writer.write::<_, _, 2>(&prepared_stream_id); - } - if let ::core::option::Option::Some(prepared_max_packet_life_time) = - prepared_max_packet_life_time - { - object_writer.write::<_, _, 2>(&prepared_max_packet_life_time); - } - if let ::core::option::Option::Some(prepared_max_retransmits) = - prepared_max_retransmits - { - object_writer.write::<_, _, 2>(&prepared_max_retransmits); - } - if let ::core::option::Option::Some(prepared_ordered) = prepared_ordered - { - object_writer.write::<_, _, 1>(&prepared_ordered); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SctpStreamParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SctpStreamParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SctpStreamParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SctpStreamParameters::create( - builder, - self.stream_id, - self.ordered, - self.max_packet_life_time, - self.max_retransmits, - ) - } - } - - /// Builder for serializing an instance of the [SctpStreamParameters] type. - /// - /// Can be created using the [SctpStreamParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SctpStreamParametersBuilder(State); - - impl SctpStreamParametersBuilder<()> { - /// Setter for the [`stream_id` field](SctpStreamParameters#structfield.stream_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn stream_id(self, value: T0) -> SctpStreamParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SctpStreamParametersBuilder((value,)) - } - - /// Sets the [`stream_id` field](SctpStreamParameters#structfield.stream_id) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn stream_id_as_default( - self, - ) -> SctpStreamParametersBuilder<(::planus::DefaultValue,)> { - self.stream_id(::planus::DefaultValue) - } - } - - impl SctpStreamParametersBuilder<(T0,)> { - /// Setter for the [`ordered` field](SctpStreamParameters#structfield.ordered). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ordered(self, value: T1) -> SctpStreamParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - SctpStreamParametersBuilder((v0, value)) - } - - /// Sets the [`ordered` field](SctpStreamParameters#structfield.ordered) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ordered_as_null(self) -> SctpStreamParametersBuilder<(T0, ())> { - self.ordered(()) - } - } - - impl SctpStreamParametersBuilder<(T0, T1)> { - /// Setter for the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_packet_life_time( - self, - value: T2, - ) -> SctpStreamParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - SctpStreamParametersBuilder((v0, v1, value)) - } - - /// Sets the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_packet_life_time_as_null( - self, - ) -> SctpStreamParametersBuilder<(T0, T1, ())> { - self.max_packet_life_time(()) - } - } - - impl SctpStreamParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_retransmits( - self, - value: T3, - ) -> SctpStreamParametersBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional, - { - let (v0, v1, v2) = self.0; - SctpStreamParametersBuilder((v0, v1, v2, value)) - } - - /// Sets the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_retransmits_as_null( - self, - ) -> SctpStreamParametersBuilder<(T0, T1, T2, ())> { - self.max_retransmits(()) - } - } - - impl SctpStreamParametersBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SctpStreamParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for SctpStreamParametersBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for SctpStreamParametersBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for SctpStreamParametersBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - SctpStreamParameters::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [SctpStreamParameters]. - #[derive(Copy, Clone)] - pub struct SctpStreamParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SctpStreamParametersRef<'a> { - /// Getter for the [`stream_id` field](SctpStreamParameters#structfield.stream_id). - #[inline] - pub fn stream_id(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SctpStreamParameters", "stream_id")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ordered` field](SctpStreamParameters#structfield.ordered). - #[inline] - pub fn ordered(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "SctpStreamParameters", "ordered") - } - - /// Getter for the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time). - #[inline] - pub fn max_packet_life_time( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0 - .access(2, "SctpStreamParameters", "max_packet_life_time") - } - - /// Getter for the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits). - #[inline] - pub fn max_retransmits(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(3, "SctpStreamParameters", "max_retransmits") - } - } - - impl<'a> ::core::fmt::Debug for SctpStreamParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SctpStreamParametersRef"); - f.field("stream_id", &self.stream_id()); - if let ::core::option::Option::Some(field_ordered) = self.ordered().transpose() - { - f.field("ordered", &field_ordered); - } - if let ::core::option::Option::Some(field_max_packet_life_time) = - self.max_packet_life_time().transpose() - { - f.field("max_packet_life_time", &field_max_packet_life_time); - } - if let ::core::option::Option::Some(field_max_retransmits) = - self.max_retransmits().transpose() - { - f.field("max_retransmits", &field_max_retransmits); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SctpStreamParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SctpStreamParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - stream_id: ::core::convert::TryInto::try_into(value.stream_id()?)?, - ordered: if let ::core::option::Option::Some(ordered) = value.ordered()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - ordered, - )?) - } else { - ::core::option::Option::None - }, - max_packet_life_time: if let ::core::option::Option::Some( - max_packet_life_time, - ) = value.max_packet_life_time()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - max_packet_life_time, - )?) - } else { - ::core::option::Option::None - }, - max_retransmits: if let ::core::option::Option::Some(max_retransmits) = - value.max_retransmits()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - max_retransmits, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SctpStreamParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SctpStreamParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SctpStreamParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SctpStreamParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SctpStreamParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SctpStreamParametersRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.DirectTransport` - /// - /// Generated from these locations: - /// * File `../worker/fbs/directTransport.fbs` - pub mod direct_transport { - /// The table `DirectTransportOptions` in the namespace `FBS.DirectTransport` - /// - /// Generated from these locations: - /// * Table `DirectTransportOptions` in the file `../worker/fbs/directTransport.fbs:5` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DirectTransportOptions { - /// The field `base` in the table `DirectTransportOptions` - pub base: ::planus::alloc::boxed::Box, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for DirectTransportOptions { - fn default() -> Self { - Self { - base: ::core::default::Default::default(), - } - } - } - - impl DirectTransportOptions { - /// Creates a [DirectTransportOptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DirectTransportOptionsBuilder<()> { - DirectTransportOptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DirectTransportOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for DirectTransportOptions - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DirectTransportOptions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DirectTransportOptions::create(builder, &self.base) - } - } - - /// Builder for serializing an instance of the [DirectTransportOptions] type. - /// - /// Can be created using the [DirectTransportOptions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DirectTransportOptionsBuilder(State); - - impl DirectTransportOptionsBuilder<()> { - /// Setter for the [`base` field](DirectTransportOptions#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> DirectTransportOptionsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DirectTransportOptionsBuilder((value,)) - } - } - - impl DirectTransportOptionsBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DirectTransportOptions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for DirectTransportOptionsBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for DirectTransportOptionsBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for DirectTransportOptionsBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - DirectTransportOptions::create(builder, v0) - } - } - - /// Reference to a deserialized [DirectTransportOptions]. - #[derive(Copy, Clone)] - pub struct DirectTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DirectTransportOptionsRef<'a> { - /// Getter for the [`base` field](DirectTransportOptions#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "DirectTransportOptions", "base") - } - } - - impl<'a> ::core::fmt::Debug for DirectTransportOptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DirectTransportOptionsRef"); - f.field("base", &self.base()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DirectTransportOptions { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DirectTransportOptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DirectTransportOptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DirectTransportOptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DirectTransportOptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DirectTransportOptions { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DirectTransportOptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[DirectTransportOptionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.DirectTransport` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/directTransport.fbs:9` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `base` in the table `DumpResponse` - pub base: ::planus::alloc::boxed::Box, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create(builder, &self.base) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`base` field](DumpResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> for DumpResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for DumpResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - DumpResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`base` field](DumpResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "DumpResponse", "base") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("base", &self.base()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.DirectTransport` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/directTransport.fbs:13` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `base` in the table `GetStatsResponse` - pub base: ::planus::alloc::boxed::Box, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create(builder, &self.base) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - GetStatsResponseBuilder((value,)) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - GetStatsResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "GetStatsResponse", "base") - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("base", &self.base()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtcpNotification` in the namespace `FBS.DirectTransport` - /// - /// Generated from these locations: - /// * Table `RtcpNotification` in the file `../worker/fbs/directTransport.fbs:19` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtcpNotification { - /// The field `data` in the table `RtcpNotification` - pub data: ::planus::alloc::vec::Vec, - } - - impl RtcpNotification { - /// Creates a [RtcpNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtcpNotificationBuilder<()> { - RtcpNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u8]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtcpNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtcpNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtcpNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtcpNotification::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [RtcpNotification] type. - /// - /// Can be created using the [RtcpNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtcpNotificationBuilder(State); - - impl RtcpNotificationBuilder<()> { - /// Setter for the [`data` field](RtcpNotification#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> RtcpNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - RtcpNotificationBuilder((value,)) - } - } - - impl RtcpNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtcpNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for RtcpNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for RtcpNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for RtcpNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - RtcpNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [RtcpNotification]. - #[derive(Copy, Clone)] - pub struct RtcpNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtcpNotificationRef<'a> { - /// Getter for the [`data` field](RtcpNotification#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "RtcpNotification", "data") - } - } - - impl<'a> ::core::fmt::Debug for RtcpNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtcpNotificationRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtcpNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtcpNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: value.data()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtcpNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtcpNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtcpNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtcpNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtcpNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtcpNotificationRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * File `../worker/fbs/transport.fbs` - pub mod transport { - /// The enum `Protocol` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Enum `Protocol` in the file `../worker/fbs/transport.fbs:11` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum Protocol { - /// The variant `UDP` in the enum `Protocol` - Udp = 1, - - /// The variant `TCP` in the enum `Protocol` - Tcp = 2, - } - - impl Protocol { - /// Array containing all valid variants of Protocol - pub const ENUM_VALUES: [Self; 2] = [Self::Udp, Self::Tcp]; - } - - impl ::core::convert::TryFrom for Protocol { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 1 => ::core::result::Result::Ok(Protocol::Udp), - 2 => ::core::result::Result::Ok(Protocol::Tcp), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: Protocol) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for Protocol { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for Protocol { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for Protocol { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Protocol { - *self - } - } - - impl ::planus::WriteAsDefault for Protocol { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &Protocol, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for Protocol { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for Protocol { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for Protocol { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "Protocol", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for Protocol { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `ListenInfo` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:16` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ListenInfo { - /// The field `protocol` in the table `ListenInfo` - pub protocol: self::Protocol, - /// The field `ip` in the table `ListenInfo` - pub ip: ::planus::alloc::string::String, - /// The field `announced_ip` in the table `ListenInfo` - pub announced_ip: ::core::option::Option<::planus::alloc::string::String>, - /// The field `port` in the table `ListenInfo` - pub port: u16, - /// The field `send_buffer_size` in the table `ListenInfo` - pub send_buffer_size: u32, - /// The field `recv_buffer_size` in the table `ListenInfo` - pub recv_buffer_size: u32, - } - - impl ListenInfo { - /// Creates a [ListenInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ListenInfoBuilder<()> { - ListenInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_protocol: impl ::planus::WriteAsDefault, - field_ip: impl ::planus::WriteAs<::planus::Offset>, - field_announced_ip: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_port: impl ::planus::WriteAsDefault, - field_send_buffer_size: impl ::planus::WriteAsDefault, - field_recv_buffer_size: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_protocol = field_protocol.prepare(builder, &self::Protocol::Udp); - let prepared_ip = field_ip.prepare(builder); - let prepared_announced_ip = field_announced_ip.prepare(builder); - let prepared_port = field_port.prepare(builder, &0); - let prepared_send_buffer_size = field_send_buffer_size.prepare(builder, &0); - let prepared_recv_buffer_size = field_recv_buffer_size.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_announced_ip.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_send_buffer_size.is_some() { - table_writer.write_entry::(4); - } - if prepared_recv_buffer_size.is_some() { - table_writer.write_entry::(5); - } - if prepared_port.is_some() { - table_writer.write_entry::(3); - } - if prepared_protocol.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_ip); - if let ::core::option::Option::Some(prepared_announced_ip) = - prepared_announced_ip - { - object_writer.write::<_, _, 4>(&prepared_announced_ip); - } - if let ::core::option::Option::Some(prepared_send_buffer_size) = - prepared_send_buffer_size - { - object_writer.write::<_, _, 4>(&prepared_send_buffer_size); - } - if let ::core::option::Option::Some(prepared_recv_buffer_size) = - prepared_recv_buffer_size - { - object_writer.write::<_, _, 4>(&prepared_recv_buffer_size); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - object_writer.write::<_, _, 2>(&prepared_port); - } - if let ::core::option::Option::Some(prepared_protocol) = - prepared_protocol - { - object_writer.write::<_, _, 1>(&prepared_protocol); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ListenInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ListenInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ListenInfo { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ListenInfo::create( - builder, - self.protocol, - &self.ip, - &self.announced_ip, - self.port, - self.send_buffer_size, - self.recv_buffer_size, - ) - } - } - - /// Builder for serializing an instance of the [ListenInfo] type. - /// - /// Can be created using the [ListenInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ListenInfoBuilder(State); - - impl ListenInfoBuilder<()> { - /// Setter for the [`protocol` field](ListenInfo#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol(self, value: T0) -> ListenInfoBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ListenInfoBuilder((value,)) - } - - /// Sets the [`protocol` field](ListenInfo#structfield.protocol) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol_as_default(self) -> ListenInfoBuilder<(::planus::DefaultValue,)> { - self.protocol(::planus::DefaultValue) - } - } - - impl ListenInfoBuilder<(T0,)> { - /// Setter for the [`ip` field](ListenInfo#structfield.ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ip(self, value: T1) -> ListenInfoBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - ListenInfoBuilder((v0, value)) - } - } - - impl ListenInfoBuilder<(T0, T1)> { - /// Setter for the [`announced_ip` field](ListenInfo#structfield.announced_ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn announced_ip(self, value: T2) -> ListenInfoBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1) = self.0; - ListenInfoBuilder((v0, v1, value)) - } - - /// Sets the [`announced_ip` field](ListenInfo#structfield.announced_ip) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn announced_ip_as_null(self) -> ListenInfoBuilder<(T0, T1, ())> { - self.announced_ip(()) - } - } - - impl ListenInfoBuilder<(T0, T1, T2)> { - /// Setter for the [`port` field](ListenInfo#structfield.port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn port(self, value: T3) -> ListenInfoBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - ListenInfoBuilder((v0, v1, v2, value)) - } - - /// Sets the [`port` field](ListenInfo#structfield.port) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn port_as_default( - self, - ) -> ListenInfoBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.port(::planus::DefaultValue) - } - } - - impl ListenInfoBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`send_buffer_size` field](ListenInfo#structfield.send_buffer_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn send_buffer_size( - self, - value: T4, - ) -> ListenInfoBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - ListenInfoBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`send_buffer_size` field](ListenInfo#structfield.send_buffer_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn send_buffer_size_as_default( - self, - ) -> ListenInfoBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.send_buffer_size(::planus::DefaultValue) - } - } - - impl ListenInfoBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`recv_buffer_size` field](ListenInfo#structfield.recv_buffer_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn recv_buffer_size( - self, - value: T5, - ) -> ListenInfoBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - ListenInfoBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`recv_buffer_size` field](ListenInfo#structfield.recv_buffer_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn recv_buffer_size_as_default( - self, - ) -> ListenInfoBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.recv_buffer_size(::planus::DefaultValue) - } - } - - impl ListenInfoBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ListenInfo]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for ListenInfoBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ListenInfoBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for ListenInfoBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - ListenInfo::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [ListenInfo]. - #[derive(Copy, Clone)] - pub struct ListenInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ListenInfoRef<'a> { - /// Getter for the [`protocol` field](ListenInfo#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ListenInfo", "protocol")? - .unwrap_or(self::Protocol::Udp), - ) - } - - /// Getter for the [`ip` field](ListenInfo#structfield.ip). - #[inline] - pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "ListenInfo", "ip") - } - - /// Getter for the [`announced_ip` field](ListenInfo#structfield.announced_ip). - #[inline] - pub fn announced_ip( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(2, "ListenInfo", "announced_ip") - } - - /// Getter for the [`port` field](ListenInfo#structfield.port). - #[inline] - pub fn port(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(3, "ListenInfo", "port")?.unwrap_or(0)) - } - - /// Getter for the [`send_buffer_size` field](ListenInfo#structfield.send_buffer_size). - #[inline] - pub fn send_buffer_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "ListenInfo", "send_buffer_size")? - .unwrap_or(0), - ) - } - - /// Getter for the [`recv_buffer_size` field](ListenInfo#structfield.recv_buffer_size). - #[inline] - pub fn recv_buffer_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "ListenInfo", "recv_buffer_size")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for ListenInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ListenInfoRef"); - f.field("protocol", &self.protocol()); - f.field("ip", &self.ip()); - if let ::core::option::Option::Some(field_announced_ip) = - self.announced_ip().transpose() - { - f.field("announced_ip", &field_announced_ip); - } - f.field("port", &self.port()); - f.field("send_buffer_size", &self.send_buffer_size()); - f.field("recv_buffer_size", &self.recv_buffer_size()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ListenInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ListenInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - ip: ::core::convert::TryInto::try_into(value.ip()?)?, - announced_ip: if let ::core::option::Option::Some(announced_ip) = - value.announced_ip()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - announced_ip, - )?) - } else { - ::core::option::Option::None - }, - port: ::core::convert::TryInto::try_into(value.port()?)?, - send_buffer_size: ::core::convert::TryInto::try_into( - value.send_buffer_size()?, - )?, - recv_buffer_size: ::core::convert::TryInto::try_into( - value.recv_buffer_size()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ListenInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ListenInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ListenInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ListenInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ListenInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ListenInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `RestartIceResponse` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:25` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RestartIceResponse { - /// The field `username_fragment` in the table `RestartIceResponse` - pub username_fragment: ::planus::alloc::string::String, - /// The field `password` in the table `RestartIceResponse` - pub password: ::planus::alloc::string::String, - /// The field `ice_lite` in the table `RestartIceResponse` - pub ice_lite: bool, - } - - impl RestartIceResponse { - /// Creates a [RestartIceResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RestartIceResponseBuilder<()> { - RestartIceResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_username_fragment: impl ::planus::WriteAs<::planus::Offset>, - field_password: impl ::planus::WriteAs<::planus::Offset>, - field_ice_lite: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_username_fragment = field_username_fragment.prepare(builder); - let prepared_password = field_password.prepare(builder); - let prepared_ice_lite = field_ice_lite.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_ice_lite.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_username_fragment); - object_writer.write::<_, _, 4>(&prepared_password); - if let ::core::option::Option::Some(prepared_ice_lite) = - prepared_ice_lite - { - object_writer.write::<_, _, 1>(&prepared_ice_lite); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RestartIceResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RestartIceResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RestartIceResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RestartIceResponse::create( - builder, - &self.username_fragment, - &self.password, - self.ice_lite, - ) - } - } - - /// Builder for serializing an instance of the [RestartIceResponse] type. - /// - /// Can be created using the [RestartIceResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RestartIceResponseBuilder(State); - - impl RestartIceResponseBuilder<()> { - /// Setter for the [`username_fragment` field](RestartIceResponse#structfield.username_fragment). - #[inline] - #[allow(clippy::type_complexity)] - pub fn username_fragment(self, value: T0) -> RestartIceResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RestartIceResponseBuilder((value,)) - } - } - - impl RestartIceResponseBuilder<(T0,)> { - /// Setter for the [`password` field](RestartIceResponse#structfield.password). - #[inline] - #[allow(clippy::type_complexity)] - pub fn password(self, value: T1) -> RestartIceResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - RestartIceResponseBuilder((v0, value)) - } - } - - impl RestartIceResponseBuilder<(T0, T1)> { - /// Setter for the [`ice_lite` field](RestartIceResponse#structfield.ice_lite). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_lite(self, value: T2) -> RestartIceResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - RestartIceResponseBuilder((v0, v1, value)) - } - - /// Sets the [`ice_lite` field](RestartIceResponse#structfield.ice_lite) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_lite_as_default( - self, - ) -> RestartIceResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.ice_lite(::planus::DefaultValue) - } - } - - impl RestartIceResponseBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RestartIceResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for RestartIceResponseBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for RestartIceResponseBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for RestartIceResponseBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - RestartIceResponse::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [RestartIceResponse]. - #[derive(Copy, Clone)] - pub struct RestartIceResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RestartIceResponseRef<'a> { - /// Getter for the [`username_fragment` field](RestartIceResponse#structfield.username_fragment). - #[inline] - pub fn username_fragment(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "RestartIceResponse", "username_fragment") - } - - /// Getter for the [`password` field](RestartIceResponse#structfield.password). - #[inline] - pub fn password(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "RestartIceResponse", "password") - } - - /// Getter for the [`ice_lite` field](RestartIceResponse#structfield.ice_lite). - #[inline] - pub fn ice_lite(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "RestartIceResponse", "ice_lite")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for RestartIceResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RestartIceResponseRef"); - f.field("username_fragment", &self.username_fragment()); - f.field("password", &self.password()); - f.field("ice_lite", &self.ice_lite()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RestartIceResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RestartIceResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - username_fragment: ::core::convert::TryInto::try_into( - value.username_fragment()?, - )?, - password: ::core::convert::TryInto::try_into(value.password()?)?, - ice_lite: ::core::convert::TryInto::try_into(value.ice_lite()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RestartIceResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RestartIceResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RestartIceResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RestartIceResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RestartIceResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RestartIceResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `ProduceRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:31` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct ProduceRequest { - /// The field `producer_id` in the table `ProduceRequest` - pub producer_id: ::planus::alloc::string::String, - /// The field `kind` in the table `ProduceRequest` - pub kind: super::rtp_parameters::MediaKind, - /// The field `rtp_parameters` in the table `ProduceRequest` - pub rtp_parameters: - ::planus::alloc::boxed::Box, - /// The field `rtp_mapping` in the table `ProduceRequest` - pub rtp_mapping: ::planus::alloc::boxed::Box, - /// The field `key_frame_request_delay` in the table `ProduceRequest` - pub key_frame_request_delay: u32, - /// The field `paused` in the table `ProduceRequest` - pub paused: bool, - } - - impl ProduceRequest { - /// Creates a [ProduceRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ProduceRequestBuilder<()> { - ProduceRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_kind: impl ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - field_rtp_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtp_mapping: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_key_frame_request_delay: impl ::planus::WriteAsDefault, - field_paused: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_producer_id = field_producer_id.prepare(builder); - let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::Audio); - let prepared_rtp_parameters = field_rtp_parameters.prepare(builder); - let prepared_rtp_mapping = field_rtp_mapping.prepare(builder); - let prepared_key_frame_request_delay = - field_key_frame_request_delay.prepare(builder, &0); - let prepared_paused = field_paused.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer - .write_entry::<::planus::Offset>(2); - table_writer - .write_entry::<::planus::Offset>(3); - if prepared_key_frame_request_delay.is_some() { - table_writer.write_entry::(4); - } - if prepared_kind.is_some() { - table_writer.write_entry::(1); - } - if prepared_paused.is_some() { - table_writer.write_entry::(5); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_id); - object_writer.write::<_, _, 4>(&prepared_rtp_parameters); - object_writer.write::<_, _, 4>(&prepared_rtp_mapping); - if let ::core::option::Option::Some(prepared_key_frame_request_delay) = - prepared_key_frame_request_delay - { - object_writer.write::<_, _, 4>(&prepared_key_frame_request_delay); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - object_writer.write::<_, _, 1>(&prepared_kind); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ProduceRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ProduceRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ProduceRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ProduceRequest::create( - builder, - &self.producer_id, - self.kind, - &self.rtp_parameters, - &self.rtp_mapping, - self.key_frame_request_delay, - self.paused, - ) - } - } - - /// Builder for serializing an instance of the [ProduceRequest] type. - /// - /// Can be created using the [ProduceRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ProduceRequestBuilder(State); - - impl ProduceRequestBuilder<()> { - /// Setter for the [`producer_id` field](ProduceRequest#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T0) -> ProduceRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ProduceRequestBuilder((value,)) - } - } - - impl ProduceRequestBuilder<(T0,)> { - /// Setter for the [`kind` field](ProduceRequest#structfield.kind). - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind(self, value: T1) -> ProduceRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - { - let (v0,) = self.0; - ProduceRequestBuilder((v0, value)) - } - - /// Sets the [`kind` field](ProduceRequest#structfield.kind) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind_as_default( - self, - ) -> ProduceRequestBuilder<(T0, ::planus::DefaultValue)> { - self.kind(::planus::DefaultValue) - } - } - - impl ProduceRequestBuilder<(T0, T1)> { - /// Setter for the [`rtp_parameters` field](ProduceRequest#structfield.rtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_parameters(self, value: T2) -> ProduceRequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - ProduceRequestBuilder((v0, v1, value)) - } - } - - impl ProduceRequestBuilder<(T0, T1, T2)> { - /// Setter for the [`rtp_mapping` field](ProduceRequest#structfield.rtp_mapping). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_mapping(self, value: T3) -> ProduceRequestBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - ProduceRequestBuilder((v0, v1, v2, value)) - } - } - - impl ProduceRequestBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`key_frame_request_delay` field](ProduceRequest#structfield.key_frame_request_delay). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key_frame_request_delay( - self, - value: T4, - ) -> ProduceRequestBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - ProduceRequestBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`key_frame_request_delay` field](ProduceRequest#structfield.key_frame_request_delay) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn key_frame_request_delay_as_default( - self, - ) -> ProduceRequestBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.key_frame_request_delay(::planus::DefaultValue) - } - } - - impl ProduceRequestBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`paused` field](ProduceRequest#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T5, - ) -> ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - ProduceRequestBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`paused` field](ProduceRequest#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> ProduceRequestBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ProduceRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - ProduceRequest::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [ProduceRequest]. - #[derive(Copy, Clone)] - pub struct ProduceRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ProduceRequestRef<'a> { - /// Getter for the [`producer_id` field](ProduceRequest#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "ProduceRequest", "producer_id") - } - - /// Getter for the [`kind` field](ProduceRequest#structfield.kind). - #[inline] - pub fn kind(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "ProduceRequest", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::Audio), - ) - } - - /// Getter for the [`rtp_parameters` field](ProduceRequest#structfield.rtp_parameters). - #[inline] - pub fn rtp_parameters( - &self, - ) -> ::planus::Result> { - self.0 - .access_required(2, "ProduceRequest", "rtp_parameters") - } - - /// Getter for the [`rtp_mapping` field](ProduceRequest#structfield.rtp_mapping). - #[inline] - pub fn rtp_mapping( - &self, - ) -> ::planus::Result> { - self.0.access_required(3, "ProduceRequest", "rtp_mapping") - } - - /// Getter for the [`key_frame_request_delay` field](ProduceRequest#structfield.key_frame_request_delay). - #[inline] - pub fn key_frame_request_delay(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "ProduceRequest", "key_frame_request_delay")? - .unwrap_or(0), - ) - } - - /// Getter for the [`paused` field](ProduceRequest#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "ProduceRequest", "paused")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for ProduceRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ProduceRequestRef"); - f.field("producer_id", &self.producer_id()); - f.field("kind", &self.kind()); - f.field("rtp_parameters", &self.rtp_parameters()); - f.field("rtp_mapping", &self.rtp_mapping()); - f.field("key_frame_request_delay", &self.key_frame_request_delay()); - f.field("paused", &self.paused()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ProduceRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ProduceRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - kind: ::core::convert::TryInto::try_into(value.kind()?)?, - rtp_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_parameters()?)?, - ), - rtp_mapping: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_mapping()?)?, - ), - key_frame_request_delay: ::core::convert::TryInto::try_into( - value.key_frame_request_delay()?, - )?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ProduceRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ProduceRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ProduceRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ProduceRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ProduceRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ProduceRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `ProduceResponse` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:40` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ProduceResponse { - /// The field `type` in the table `ProduceResponse` - pub type_: super::rtp_parameters::Type, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ProduceResponse { - fn default() -> Self { - Self { - type_: super::rtp_parameters::Type::Simple, - } - } - } - - impl ProduceResponse { - /// Creates a [ProduceResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ProduceResponseBuilder<()> { - ProduceResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - ) -> ::planus::Offset { - let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_type_.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ProduceResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ProduceResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ProduceResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ProduceResponse::create(builder, self.type_) - } - } - - /// Builder for serializing an instance of the [ProduceResponse] type. - /// - /// Can be created using the [ProduceResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ProduceResponseBuilder(State); - - impl ProduceResponseBuilder<()> { - /// Setter for the [`type` field](ProduceResponse#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> ProduceResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - { - ProduceResponseBuilder((value,)) - } - - /// Sets the [`type` field](ProduceResponse#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default(self) -> ProduceResponseBuilder<(::planus::DefaultValue,)> { - self.type_(::planus::DefaultValue) - } - } - - impl ProduceResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ProduceResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - > ::planus::WriteAs<::planus::Offset> - for ProduceResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for ProduceResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - > ::planus::WriteAsOffset for ProduceResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ProduceResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [ProduceResponse]. - #[derive(Copy, Clone)] - pub struct ProduceResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ProduceResponseRef<'a> { - /// Getter for the [`type` field](ProduceResponse#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ProduceResponse", "type_")? - .unwrap_or(super::rtp_parameters::Type::Simple), - ) - } - } - - impl<'a> ::core::fmt::Debug for ProduceResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ProduceResponseRef"); - f.field("type_", &self.type_()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ProduceResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ProduceResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ProduceResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ProduceResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ProduceResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ProduceResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ProduceResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ProduceResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConsumeRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:44` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct ConsumeRequest { - /// The field `consumer_id` in the table `ConsumeRequest` - pub consumer_id: ::planus::alloc::string::String, - /// The field `producer_id` in the table `ConsumeRequest` - pub producer_id: ::planus::alloc::string::String, - /// The field `kind` in the table `ConsumeRequest` - pub kind: super::rtp_parameters::MediaKind, - /// The field `rtp_parameters` in the table `ConsumeRequest` - pub rtp_parameters: - ::planus::alloc::boxed::Box, - /// The field `type` in the table `ConsumeRequest` - pub type_: super::rtp_parameters::Type, - /// The field `consumable_rtp_encodings` in the table `ConsumeRequest` - pub consumable_rtp_encodings: - ::planus::alloc::vec::Vec, - /// The field `paused` in the table `ConsumeRequest` - pub paused: bool, - /// The field `preferred_layers` in the table `ConsumeRequest` - pub preferred_layers: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `ignore_dtx` in the table `ConsumeRequest` - pub ignore_dtx: bool, - } - - impl ConsumeRequest { - /// Creates a [ConsumeRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConsumeRequestBuilder<()> { - ConsumeRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_consumer_id: impl ::planus::WriteAs<::planus::Offset>, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_kind: impl ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - field_rtp_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_type_: impl ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - field_consumable_rtp_encodings: impl ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - field_paused: impl ::planus::WriteAsDefault, - field_preferred_layers: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_ignore_dtx: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_consumer_id = field_consumer_id.prepare(builder); - let prepared_producer_id = field_producer_id.prepare(builder); - let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::Audio); - let prepared_rtp_parameters = field_rtp_parameters.prepare(builder); - let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); - let prepared_consumable_rtp_encodings = - field_consumable_rtp_encodings.prepare(builder); - let prepared_paused = field_paused.prepare(builder, &false); - let prepared_preferred_layers = field_preferred_layers.prepare(builder); - let prepared_ignore_dtx = field_ignore_dtx.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<22> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - table_writer - .write_entry::<::planus::Offset>(3); - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(5); - if prepared_preferred_layers.is_some() { - table_writer - .write_entry::<::planus::Offset>(7); - } - if prepared_kind.is_some() { - table_writer.write_entry::(2); - } - if prepared_type_.is_some() { - table_writer.write_entry::(4); - } - if prepared_paused.is_some() { - table_writer.write_entry::(6); - } - if prepared_ignore_dtx.is_some() { - table_writer.write_entry::(8); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_consumer_id); - object_writer.write::<_, _, 4>(&prepared_producer_id); - object_writer.write::<_, _, 4>(&prepared_rtp_parameters); - object_writer.write::<_, _, 4>(&prepared_consumable_rtp_encodings); - if let ::core::option::Option::Some(prepared_preferred_layers) = - prepared_preferred_layers - { - object_writer.write::<_, _, 4>(&prepared_preferred_layers); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - object_writer.write::<_, _, 1>(&prepared_kind); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - if let ::core::option::Option::Some(prepared_ignore_dtx) = - prepared_ignore_dtx - { - object_writer.write::<_, _, 1>(&prepared_ignore_dtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConsumeRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConsumeRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConsumeRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConsumeRequest::create( - builder, - &self.consumer_id, - &self.producer_id, - self.kind, - &self.rtp_parameters, - self.type_, - &self.consumable_rtp_encodings, - self.paused, - &self.preferred_layers, - self.ignore_dtx, - ) - } - } - - /// Builder for serializing an instance of the [ConsumeRequest] type. - /// - /// Can be created using the [ConsumeRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConsumeRequestBuilder(State); - - impl ConsumeRequestBuilder<()> { - /// Setter for the [`consumer_id` field](ConsumeRequest#structfield.consumer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn consumer_id(self, value: T0) -> ConsumeRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConsumeRequestBuilder((value,)) - } - } - - impl ConsumeRequestBuilder<(T0,)> { - /// Setter for the [`producer_id` field](ConsumeRequest#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T1) -> ConsumeRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - ConsumeRequestBuilder((v0, value)) - } - } - - impl ConsumeRequestBuilder<(T0, T1)> { - /// Setter for the [`kind` field](ConsumeRequest#structfield.kind). - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind(self, value: T2) -> ConsumeRequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - { - let (v0, v1) = self.0; - ConsumeRequestBuilder((v0, v1, value)) - } - - /// Sets the [`kind` field](ConsumeRequest#structfield.kind) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind_as_default( - self, - ) -> ConsumeRequestBuilder<(T0, T1, ::planus::DefaultValue)> { - self.kind(::planus::DefaultValue) - } - } - - impl ConsumeRequestBuilder<(T0, T1, T2)> { - /// Setter for the [`rtp_parameters` field](ConsumeRequest#structfield.rtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_parameters( - self, - value: T3, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - ConsumeRequestBuilder((v0, v1, v2, value)) - } - } - - impl ConsumeRequestBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`type` field](ConsumeRequest#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T4) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - { - let (v0, v1, v2, v3) = self.0; - ConsumeRequestBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`type` field](ConsumeRequest#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.type_(::planus::DefaultValue) - } - } - - impl ConsumeRequestBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`consumable_rtp_encodings` field](ConsumeRequest#structfield.consumable_rtp_encodings). - #[inline] - #[allow(clippy::type_complexity)] - pub fn consumable_rtp_encodings( - self, - value: T5, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - ConsumeRequestBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`paused` field](ConsumeRequest#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T6, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - ConsumeRequestBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`paused` field](ConsumeRequest#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`preferred_layers` field](ConsumeRequest#structfield.preferred_layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers( - self, - value: T7, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - ConsumeRequestBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`preferred_layers` field](ConsumeRequest#structfield.preferred_layers) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers_as_null( - self, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, ())> { - self.preferred_layers(()) - } - } - - impl ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`ignore_dtx` field](ConsumeRequest#structfield.ignore_dtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ignore_dtx( - self, - value: T8, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - ConsumeRequestBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`ignore_dtx` field](ConsumeRequest#structfield.ignore_dtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ignore_dtx_as_default( - self, - ) -> ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> - { - self.ignore_dtx(::planus::DefaultValue) - } - } - - impl - ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConsumeRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsOptional<::planus::Offset>, - T8: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsOptional<::planus::Offset>, - T8: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T5: ::planus::WriteAs< - ::planus::Offset< - [::planus::Offset], - >, - >, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsOptional<::planus::Offset>, - T8: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for ConsumeRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = &self.0; - ConsumeRequest::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8) - } - } - - /// Reference to a deserialized [ConsumeRequest]. - #[derive(Copy, Clone)] - pub struct ConsumeRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConsumeRequestRef<'a> { - /// Getter for the [`consumer_id` field](ConsumeRequest#structfield.consumer_id). - #[inline] - pub fn consumer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "ConsumeRequest", "consumer_id") - } - - /// Getter for the [`producer_id` field](ConsumeRequest#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "ConsumeRequest", "producer_id") - } - - /// Getter for the [`kind` field](ConsumeRequest#structfield.kind). - #[inline] - pub fn kind(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "ConsumeRequest", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::Audio), - ) - } - - /// Getter for the [`rtp_parameters` field](ConsumeRequest#structfield.rtp_parameters). - #[inline] - pub fn rtp_parameters( - &self, - ) -> ::planus::Result> { - self.0 - .access_required(3, "ConsumeRequest", "rtp_parameters") - } - - /// Getter for the [`type` field](ConsumeRequest#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "ConsumeRequest", "type_")? - .unwrap_or(super::rtp_parameters::Type::Simple), - ) - } - - /// Getter for the [`consumable_rtp_encodings` field](ConsumeRequest#structfield.consumable_rtp_encodings). - #[inline] - pub fn consumable_rtp_encodings( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::planus::Result>, - >, - > { - self.0 - .access_required(5, "ConsumeRequest", "consumable_rtp_encodings") - } - - /// Getter for the [`paused` field](ConsumeRequest#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "ConsumeRequest", "paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`preferred_layers` field](ConsumeRequest#structfield.preferred_layers). - #[inline] - pub fn preferred_layers( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(7, "ConsumeRequest", "preferred_layers") - } - - /// Getter for the [`ignore_dtx` field](ConsumeRequest#structfield.ignore_dtx). - #[inline] - pub fn ignore_dtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(8, "ConsumeRequest", "ignore_dtx")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for ConsumeRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConsumeRequestRef"); - f.field("consumer_id", &self.consumer_id()); - f.field("producer_id", &self.producer_id()); - f.field("kind", &self.kind()); - f.field("rtp_parameters", &self.rtp_parameters()); - f.field("type_", &self.type_()); - f.field("consumable_rtp_encodings", &self.consumable_rtp_encodings()); - f.field("paused", &self.paused()); - if let ::core::option::Option::Some(field_preferred_layers) = - self.preferred_layers().transpose() - { - f.field("preferred_layers", &field_preferred_layers); - } - f.field("ignore_dtx", &self.ignore_dtx()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConsumeRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConsumeRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - consumer_id: ::core::convert::TryInto::try_into(value.consumer_id()?)?, - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - kind: ::core::convert::TryInto::try_into(value.kind()?)?, - rtp_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_parameters()?)?, - ), - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - consumable_rtp_encodings: value - .consumable_rtp_encodings()? - .to_vec_result()?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - preferred_layers: if let ::core::option::Option::Some(preferred_layers) = - value.preferred_layers()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(preferred_layers)?, - )) - } else { - ::core::option::Option::None - }, - ignore_dtx: ::core::convert::TryInto::try_into(value.ignore_dtx()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConsumeRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConsumeRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConsumeRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConsumeRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConsumeRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConsumeRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConsumeResponse` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:56` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConsumeResponse { - /// The field `paused` in the table `ConsumeResponse` - pub paused: bool, - /// The field `producer_paused` in the table `ConsumeResponse` - pub producer_paused: bool, - /// The field `score` in the table `ConsumeResponse` - pub score: ::planus::alloc::boxed::Box, - /// The field `preferred_layers` in the table `ConsumeResponse` - pub preferred_layers: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - } - - impl ConsumeResponse { - /// Creates a [ConsumeResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConsumeResponseBuilder<()> { - ConsumeResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_paused: impl ::planus::WriteAsDefault, - field_producer_paused: impl ::planus::WriteAsDefault, - field_score: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_preferred_layers: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_paused = field_paused.prepare(builder, &false); - let prepared_producer_paused = field_producer_paused.prepare(builder, &false); - let prepared_score = field_score.prepare(builder); - let prepared_preferred_layers = field_preferred_layers.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(2); - if prepared_preferred_layers.is_some() { - table_writer - .write_entry::<::planus::Offset>(3); - } - if prepared_paused.is_some() { - table_writer.write_entry::(0); - } - if prepared_producer_paused.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_score); - if let ::core::option::Option::Some(prepared_preferred_layers) = - prepared_preferred_layers - { - object_writer.write::<_, _, 4>(&prepared_preferred_layers); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - if let ::core::option::Option::Some(prepared_producer_paused) = - prepared_producer_paused - { - object_writer.write::<_, _, 1>(&prepared_producer_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConsumeResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConsumeResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConsumeResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConsumeResponse::create( - builder, - self.paused, - self.producer_paused, - &self.score, - &self.preferred_layers, - ) - } - } - - /// Builder for serializing an instance of the [ConsumeResponse] type. - /// - /// Can be created using the [ConsumeResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConsumeResponseBuilder(State); - - impl ConsumeResponseBuilder<()> { - /// Setter for the [`paused` field](ConsumeResponse#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused(self, value: T0) -> ConsumeResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ConsumeResponseBuilder((value,)) - } - - /// Sets the [`paused` field](ConsumeResponse#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> ConsumeResponseBuilder<(::planus::DefaultValue,)> { - self.paused(::planus::DefaultValue) - } - } - - impl ConsumeResponseBuilder<(T0,)> { - /// Setter for the [`producer_paused` field](ConsumeResponse#structfield.producer_paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_paused(self, value: T1) -> ConsumeResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ConsumeResponseBuilder((v0, value)) - } - - /// Sets the [`producer_paused` field](ConsumeResponse#structfield.producer_paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_paused_as_default( - self, - ) -> ConsumeResponseBuilder<(T0, ::planus::DefaultValue)> { - self.producer_paused(::planus::DefaultValue) - } - } - - impl ConsumeResponseBuilder<(T0, T1)> { - /// Setter for the [`score` field](ConsumeResponse#structfield.score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn score(self, value: T2) -> ConsumeResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - ConsumeResponseBuilder((v0, v1, value)) - } - } - - impl ConsumeResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`preferred_layers` field](ConsumeResponse#structfield.preferred_layers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers( - self, - value: T3, - ) -> ConsumeResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2) = self.0; - ConsumeResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`preferred_layers` field](ConsumeResponse#structfield.preferred_layers) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_layers_as_null(self) -> ConsumeResponseBuilder<(T0, T1, T2, ())> { - self.preferred_layers(()) - } - } - - impl ConsumeResponseBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConsumeResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for ConsumeResponseBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for ConsumeResponseBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOffset - for ConsumeResponseBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - ConsumeResponse::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [ConsumeResponse]. - #[derive(Copy, Clone)] - pub struct ConsumeResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConsumeResponseRef<'a> { - /// Getter for the [`paused` field](ConsumeResponse#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ConsumeResponse", "paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`producer_paused` field](ConsumeResponse#structfield.producer_paused). - #[inline] - pub fn producer_paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "ConsumeResponse", "producer_paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`score` field](ConsumeResponse#structfield.score). - #[inline] - pub fn score(&self) -> ::planus::Result> { - self.0.access_required(2, "ConsumeResponse", "score") - } - - /// Getter for the [`preferred_layers` field](ConsumeResponse#structfield.preferred_layers). - #[inline] - pub fn preferred_layers( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(3, "ConsumeResponse", "preferred_layers") - } - } - - impl<'a> ::core::fmt::Debug for ConsumeResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConsumeResponseRef"); - f.field("paused", &self.paused()); - f.field("producer_paused", &self.producer_paused()); - f.field("score", &self.score()); - if let ::core::option::Option::Some(field_preferred_layers) = - self.preferred_layers().transpose() - { - f.field("preferred_layers", &field_preferred_layers); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConsumeResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConsumeResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - producer_paused: ::core::convert::TryInto::try_into( - value.producer_paused()?, - )?, - score: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.score()?)?, - ), - preferred_layers: if let ::core::option::Option::Some(preferred_layers) = - value.preferred_layers()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(preferred_layers)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConsumeResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConsumeResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConsumeResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConsumeResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConsumeResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConsumeResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `ProduceDataRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:63` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ProduceDataRequest { - /// The field `data_producer_id` in the table `ProduceDataRequest` - pub data_producer_id: ::planus::alloc::string::String, - /// The field `type` in the table `ProduceDataRequest` - pub type_: super::data_producer::Type, - /// The field `sctp_stream_parameters` in the table `ProduceDataRequest` - pub sctp_stream_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `label` in the table `ProduceDataRequest` - pub label: ::core::option::Option<::planus::alloc::string::String>, - /// The field `protocol` in the table `ProduceDataRequest` - pub protocol: ::core::option::Option<::planus::alloc::string::String>, - /// The field `paused` in the table `ProduceDataRequest` - pub paused: bool, - } - - impl ProduceDataRequest { - /// Creates a [ProduceDataRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ProduceDataRequestBuilder<()> { - ProduceDataRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: impl ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - field_sctp_stream_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_label: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_protocol: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_paused: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_data_producer_id = field_data_producer_id.prepare(builder); - let prepared_type_ = - field_type_.prepare(builder, &super::data_producer::Type::Sctp); - let prepared_sctp_stream_parameters = - field_sctp_stream_parameters.prepare(builder); - let prepared_label = field_label.prepare(builder); - let prepared_protocol = field_protocol.prepare(builder); - let prepared_paused = field_paused.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_sctp_stream_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_label.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_protocol.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_type_.is_some() { - table_writer.write_entry::(1); - } - if prepared_paused.is_some() { - table_writer.write_entry::(5); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data_producer_id); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - object_writer.write::<_, _, 4>(&prepared_sctp_stream_parameters); - } - if let ::core::option::Option::Some(prepared_label) = prepared_label { - object_writer.write::<_, _, 4>(&prepared_label); - } - if let ::core::option::Option::Some(prepared_protocol) = - prepared_protocol - { - object_writer.write::<_, _, 4>(&prepared_protocol); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ProduceDataRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ProduceDataRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ProduceDataRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ProduceDataRequest::create( - builder, - &self.data_producer_id, - self.type_, - &self.sctp_stream_parameters, - &self.label, - &self.protocol, - self.paused, - ) - } - } - - /// Builder for serializing an instance of the [ProduceDataRequest] type. - /// - /// Can be created using the [ProduceDataRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ProduceDataRequestBuilder(State); - - impl ProduceDataRequestBuilder<()> { - /// Setter for the [`data_producer_id` field](ProduceDataRequest#structfield.data_producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_id(self, value: T0) -> ProduceDataRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ProduceDataRequestBuilder((value,)) - } - } - - impl ProduceDataRequestBuilder<(T0,)> { - /// Setter for the [`type` field](ProduceDataRequest#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T1) -> ProduceDataRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - { - let (v0,) = self.0; - ProduceDataRequestBuilder((v0, value)) - } - - /// Sets the [`type` field](ProduceDataRequest#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> ProduceDataRequestBuilder<(T0, ::planus::DefaultValue)> { - self.type_(::planus::DefaultValue) - } - } - - impl ProduceDataRequestBuilder<(T0, T1)> { - /// Setter for the [`sctp_stream_parameters` field](ProduceDataRequest#structfield.sctp_stream_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters( - self, - value: T2, - ) -> ProduceDataRequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1) = self.0; - ProduceDataRequestBuilder((v0, v1, value)) - } - - /// Sets the [`sctp_stream_parameters` field](ProduceDataRequest#structfield.sctp_stream_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters_as_null( - self, - ) -> ProduceDataRequestBuilder<(T0, T1, ())> { - self.sctp_stream_parameters(()) - } - } - - impl ProduceDataRequestBuilder<(T0, T1, T2)> { - /// Setter for the [`label` field](ProduceDataRequest#structfield.label). - #[inline] - #[allow(clippy::type_complexity)] - pub fn label(self, value: T3) -> ProduceDataRequestBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2) = self.0; - ProduceDataRequestBuilder((v0, v1, v2, value)) - } - - /// Sets the [`label` field](ProduceDataRequest#structfield.label) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn label_as_null(self) -> ProduceDataRequestBuilder<(T0, T1, T2, ())> { - self.label(()) - } - } - - impl ProduceDataRequestBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`protocol` field](ProduceDataRequest#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol( - self, - value: T4, - ) -> ProduceDataRequestBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3) = self.0; - ProduceDataRequestBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`protocol` field](ProduceDataRequest#structfield.protocol) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol_as_null(self) -> ProduceDataRequestBuilder<(T0, T1, T2, T3, ())> { - self.protocol(()) - } - } - - impl ProduceDataRequestBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`paused` field](ProduceDataRequest#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T5, - ) -> ProduceDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - ProduceDataRequestBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`paused` field](ProduceDataRequest#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> ProduceDataRequestBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl ProduceDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ProduceDataRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for ProduceDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ProduceDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for ProduceDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - ProduceDataRequest::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [ProduceDataRequest]. - #[derive(Copy, Clone)] - pub struct ProduceDataRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ProduceDataRequestRef<'a> { - /// Getter for the [`data_producer_id` field](ProduceDataRequest#structfield.data_producer_id). - #[inline] - pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "ProduceDataRequest", "data_producer_id") - } - - /// Getter for the [`type` field](ProduceDataRequest#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "ProduceDataRequest", "type_")? - .unwrap_or(super::data_producer::Type::Sctp), - ) - } - - /// Getter for the [`sctp_stream_parameters` field](ProduceDataRequest#structfield.sctp_stream_parameters). - #[inline] - pub fn sctp_stream_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0 - .access(2, "ProduceDataRequest", "sctp_stream_parameters") - } - - /// Getter for the [`label` field](ProduceDataRequest#structfield.label). - #[inline] - pub fn label( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(3, "ProduceDataRequest", "label") - } - - /// Getter for the [`protocol` field](ProduceDataRequest#structfield.protocol). - #[inline] - pub fn protocol( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(4, "ProduceDataRequest", "protocol") - } - - /// Getter for the [`paused` field](ProduceDataRequest#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "ProduceDataRequest", "paused")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for ProduceDataRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ProduceDataRequestRef"); - f.field("data_producer_id", &self.data_producer_id()); - f.field("type_", &self.type_()); - if let ::core::option::Option::Some(field_sctp_stream_parameters) = - self.sctp_stream_parameters().transpose() - { - f.field("sctp_stream_parameters", &field_sctp_stream_parameters); - } - if let ::core::option::Option::Some(field_label) = self.label().transpose() { - f.field("label", &field_label); - } - if let ::core::option::Option::Some(field_protocol) = - self.protocol().transpose() - { - f.field("protocol", &field_protocol); - } - f.field("paused", &self.paused()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ProduceDataRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ProduceDataRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data_producer_id: ::core::convert::TryInto::try_into( - value.data_producer_id()?, - )?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - sctp_stream_parameters: if let ::core::option::Option::Some( - sctp_stream_parameters, - ) = value.sctp_stream_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(sctp_stream_parameters)?, - )) - } else { - ::core::option::Option::None - }, - label: if let ::core::option::Option::Some(label) = value.label()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(label)?) - } else { - ::core::option::Option::None - }, - protocol: if let ::core::option::Option::Some(protocol) = - value.protocol()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - protocol, - )?) - } else { - ::core::option::Option::None - }, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ProduceDataRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ProduceDataRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ProduceDataRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ProduceDataRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ProduceDataRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ProduceDataRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConsumeDataRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:72` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConsumeDataRequest { - /// The field `data_consumer_id` in the table `ConsumeDataRequest` - pub data_consumer_id: ::planus::alloc::string::String, - /// The field `data_producer_id` in the table `ConsumeDataRequest` - pub data_producer_id: ::planus::alloc::string::String, - /// The field `type` in the table `ConsumeDataRequest` - pub type_: super::data_producer::Type, - /// The field `sctp_stream_parameters` in the table `ConsumeDataRequest` - pub sctp_stream_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `label` in the table `ConsumeDataRequest` - pub label: ::core::option::Option<::planus::alloc::string::String>, - /// The field `protocol` in the table `ConsumeDataRequest` - pub protocol: ::core::option::Option<::planus::alloc::string::String>, - /// The field `paused` in the table `ConsumeDataRequest` - pub paused: bool, - /// The field `subchannels` in the table `ConsumeDataRequest` - pub subchannels: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - impl ConsumeDataRequest { - /// Creates a [ConsumeDataRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConsumeDataRequestBuilder<()> { - ConsumeDataRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data_consumer_id: impl ::planus::WriteAs<::planus::Offset>, - field_data_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: impl ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - field_sctp_stream_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_label: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_protocol: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_paused: impl ::planus::WriteAsDefault, - field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - ) -> ::planus::Offset { - let prepared_data_consumer_id = field_data_consumer_id.prepare(builder); - let prepared_data_producer_id = field_data_producer_id.prepare(builder); - let prepared_type_ = - field_type_.prepare(builder, &super::data_producer::Type::Sctp); - let prepared_sctp_stream_parameters = - field_sctp_stream_parameters.prepare(builder); - let prepared_label = field_label.prepare(builder); - let prepared_protocol = field_protocol.prepare(builder); - let prepared_paused = field_paused.prepare(builder, &false); - let prepared_subchannels = field_subchannels.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_sctp_stream_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_label.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_protocol.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - if prepared_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(7); - } - if prepared_type_.is_some() { - table_writer.write_entry::(2); - } - if prepared_paused.is_some() { - table_writer.write_entry::(6); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data_consumer_id); - object_writer.write::<_, _, 4>(&prepared_data_producer_id); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - object_writer.write::<_, _, 4>(&prepared_sctp_stream_parameters); - } - if let ::core::option::Option::Some(prepared_label) = prepared_label { - object_writer.write::<_, _, 4>(&prepared_label); - } - if let ::core::option::Option::Some(prepared_protocol) = - prepared_protocol - { - object_writer.write::<_, _, 4>(&prepared_protocol); - } - if let ::core::option::Option::Some(prepared_subchannels) = - prepared_subchannels - { - object_writer.write::<_, _, 4>(&prepared_subchannels); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConsumeDataRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConsumeDataRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConsumeDataRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConsumeDataRequest::create( - builder, - &self.data_consumer_id, - &self.data_producer_id, - self.type_, - &self.sctp_stream_parameters, - &self.label, - &self.protocol, - self.paused, - &self.subchannels, - ) - } - } - - /// Builder for serializing an instance of the [ConsumeDataRequest] type. - /// - /// Can be created using the [ConsumeDataRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConsumeDataRequestBuilder(State); - - impl ConsumeDataRequestBuilder<()> { - /// Setter for the [`data_consumer_id` field](ConsumeDataRequest#structfield.data_consumer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_consumer_id(self, value: T0) -> ConsumeDataRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConsumeDataRequestBuilder((value,)) - } - } - - impl ConsumeDataRequestBuilder<(T0,)> { - /// Setter for the [`data_producer_id` field](ConsumeDataRequest#structfield.data_producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_id(self, value: T1) -> ConsumeDataRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - ConsumeDataRequestBuilder((v0, value)) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1)> { - /// Setter for the [`type` field](ConsumeDataRequest#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T2) -> ConsumeDataRequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - { - let (v0, v1) = self.0; - ConsumeDataRequestBuilder((v0, v1, value)) - } - - /// Sets the [`type` field](ConsumeDataRequest#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> ConsumeDataRequestBuilder<(T0, T1, ::planus::DefaultValue)> { - self.type_(::planus::DefaultValue) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1, T2)> { - /// Setter for the [`sctp_stream_parameters` field](ConsumeDataRequest#structfield.sctp_stream_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters( - self, - value: T3, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2) = self.0; - ConsumeDataRequestBuilder((v0, v1, v2, value)) - } - - /// Sets the [`sctp_stream_parameters` field](ConsumeDataRequest#structfield.sctp_stream_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_stream_parameters_as_null( - self, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, ())> { - self.sctp_stream_parameters(()) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`label` field](ConsumeDataRequest#structfield.label). - #[inline] - #[allow(clippy::type_complexity)] - pub fn label(self, value: T4) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3) = self.0; - ConsumeDataRequestBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`label` field](ConsumeDataRequest#structfield.label) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn label_as_null(self) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, ())> { - self.label(()) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`protocol` field](ConsumeDataRequest#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol( - self, - value: T5, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3, v4) = self.0; - ConsumeDataRequestBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`protocol` field](ConsumeDataRequest#structfield.protocol) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol_as_null( - self, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, ())> { - self.protocol(()) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`paused` field](ConsumeDataRequest#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T6, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - ConsumeDataRequestBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`paused` field](ConsumeDataRequest#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`subchannels` field](ConsumeDataRequest#structfield.subchannels). - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels( - self, - value: T7, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - ConsumeDataRequestBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`subchannels` field](ConsumeDataRequest#structfield.subchannels) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels_as_null( - self, - ) -> ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, ())> { - self.subchannels(()) - } - } - - impl ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConsumeDataRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - > ::planus::WriteAs<::planus::Offset> - for ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< - super::data_producer::Type, - super::data_producer::Type, - >, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - > ::planus::WriteAsOffset - for ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - ConsumeDataRequest::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [ConsumeDataRequest]. - #[derive(Copy, Clone)] - pub struct ConsumeDataRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConsumeDataRequestRef<'a> { - /// Getter for the [`data_consumer_id` field](ConsumeDataRequest#structfield.data_consumer_id). - #[inline] - pub fn data_consumer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "ConsumeDataRequest", "data_consumer_id") - } - - /// Getter for the [`data_producer_id` field](ConsumeDataRequest#structfield.data_producer_id). - #[inline] - pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(1, "ConsumeDataRequest", "data_producer_id") - } - - /// Getter for the [`type` field](ConsumeDataRequest#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "ConsumeDataRequest", "type_")? - .unwrap_or(super::data_producer::Type::Sctp), - ) - } - - /// Getter for the [`sctp_stream_parameters` field](ConsumeDataRequest#structfield.sctp_stream_parameters). - #[inline] - pub fn sctp_stream_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0 - .access(3, "ConsumeDataRequest", "sctp_stream_parameters") - } - - /// Getter for the [`label` field](ConsumeDataRequest#structfield.label). - #[inline] - pub fn label( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(4, "ConsumeDataRequest", "label") - } - - /// Getter for the [`protocol` field](ConsumeDataRequest#structfield.protocol). - #[inline] - pub fn protocol( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(5, "ConsumeDataRequest", "protocol") - } - - /// Getter for the [`paused` field](ConsumeDataRequest#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "ConsumeDataRequest", "paused")? - .unwrap_or(false), - ) - } - - /// Getter for the [`subchannels` field](ConsumeDataRequest#structfield.subchannels). - #[inline] - pub fn subchannels( - &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> - { - self.0.access(7, "ConsumeDataRequest", "subchannels") - } - } - - impl<'a> ::core::fmt::Debug for ConsumeDataRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConsumeDataRequestRef"); - f.field("data_consumer_id", &self.data_consumer_id()); - f.field("data_producer_id", &self.data_producer_id()); - f.field("type_", &self.type_()); - if let ::core::option::Option::Some(field_sctp_stream_parameters) = - self.sctp_stream_parameters().transpose() - { - f.field("sctp_stream_parameters", &field_sctp_stream_parameters); - } - if let ::core::option::Option::Some(field_label) = self.label().transpose() { - f.field("label", &field_label); - } - if let ::core::option::Option::Some(field_protocol) = - self.protocol().transpose() - { - f.field("protocol", &field_protocol); - } - f.field("paused", &self.paused()); - if let ::core::option::Option::Some(field_subchannels) = - self.subchannels().transpose() - { - f.field("subchannels", &field_subchannels); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConsumeDataRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConsumeDataRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data_consumer_id: ::core::convert::TryInto::try_into( - value.data_consumer_id()?, - )?, - data_producer_id: ::core::convert::TryInto::try_into( - value.data_producer_id()?, - )?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - sctp_stream_parameters: if let ::core::option::Option::Some( - sctp_stream_parameters, - ) = value.sctp_stream_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(sctp_stream_parameters)?, - )) - } else { - ::core::option::Option::None - }, - label: if let ::core::option::Option::Some(label) = value.label()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(label)?) - } else { - ::core::option::Option::None - }, - protocol: if let ::core::option::Option::Some(protocol) = - value.protocol()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - protocol, - )?) - } else { - ::core::option::Option::None - }, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - subchannels: if let ::core::option::Option::Some(subchannels) = - value.subchannels()? - { - ::core::option::Option::Some(subchannels.to_vec()?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConsumeDataRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConsumeDataRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConsumeDataRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConsumeDataRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConsumeDataRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConsumeDataRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `Tuple` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:83` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Tuple { - /// The field `local_ip` in the table `Tuple` - pub local_ip: ::planus::alloc::string::String, - /// The field `local_port` in the table `Tuple` - pub local_port: u16, - /// The field `remote_ip` in the table `Tuple` - pub remote_ip: ::core::option::Option<::planus::alloc::string::String>, - /// The field `remote_port` in the table `Tuple` - pub remote_port: u16, - /// The field `protocol` in the table `Tuple` - pub protocol: self::Protocol, - } - - impl Tuple { - /// Creates a [TupleBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TupleBuilder<()> { - TupleBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_local_ip: impl ::planus::WriteAs<::planus::Offset>, - field_local_port: impl ::planus::WriteAsDefault, - field_remote_ip: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_remote_port: impl ::planus::WriteAsDefault, - field_protocol: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_local_ip = field_local_ip.prepare(builder); - let prepared_local_port = field_local_port.prepare(builder, &0); - let prepared_remote_ip = field_remote_ip.prepare(builder); - let prepared_remote_port = field_remote_port.prepare(builder, &0); - let prepared_protocol = field_protocol.prepare(builder, &self::Protocol::Udp); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_remote_ip.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_local_port.is_some() { - table_writer.write_entry::(1); - } - if prepared_remote_port.is_some() { - table_writer.write_entry::(3); - } - if prepared_protocol.is_some() { - table_writer.write_entry::(4); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_local_ip); - if let ::core::option::Option::Some(prepared_remote_ip) = - prepared_remote_ip - { - object_writer.write::<_, _, 4>(&prepared_remote_ip); - } - if let ::core::option::Option::Some(prepared_local_port) = - prepared_local_port - { - object_writer.write::<_, _, 2>(&prepared_local_port); - } - if let ::core::option::Option::Some(prepared_remote_port) = - prepared_remote_port - { - object_writer.write::<_, _, 2>(&prepared_remote_port); - } - if let ::core::option::Option::Some(prepared_protocol) = - prepared_protocol - { - object_writer.write::<_, _, 1>(&prepared_protocol); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Tuple { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Tuple { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Tuple { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Tuple::create( - builder, - &self.local_ip, - self.local_port, - &self.remote_ip, - self.remote_port, - self.protocol, - ) - } - } - - /// Builder for serializing an instance of the [Tuple] type. - /// - /// Can be created using the [Tuple::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TupleBuilder(State); - - impl TupleBuilder<()> { - /// Setter for the [`local_ip` field](Tuple#structfield.local_ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_ip(self, value: T0) -> TupleBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - TupleBuilder((value,)) - } - } - - impl TupleBuilder<(T0,)> { - /// Setter for the [`local_port` field](Tuple#structfield.local_port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_port(self, value: T1) -> TupleBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - TupleBuilder((v0, value)) - } - - /// Sets the [`local_port` field](Tuple#structfield.local_port) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_port_as_default(self) -> TupleBuilder<(T0, ::planus::DefaultValue)> { - self.local_port(::planus::DefaultValue) - } - } - - impl TupleBuilder<(T0, T1)> { - /// Setter for the [`remote_ip` field](Tuple#structfield.remote_ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn remote_ip(self, value: T2) -> TupleBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1) = self.0; - TupleBuilder((v0, v1, value)) - } - - /// Sets the [`remote_ip` field](Tuple#structfield.remote_ip) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn remote_ip_as_null(self) -> TupleBuilder<(T0, T1, ())> { - self.remote_ip(()) - } - } - - impl TupleBuilder<(T0, T1, T2)> { - /// Setter for the [`remote_port` field](Tuple#structfield.remote_port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn remote_port(self, value: T3) -> TupleBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - TupleBuilder((v0, v1, v2, value)) - } - - /// Sets the [`remote_port` field](Tuple#structfield.remote_port) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn remote_port_as_default( - self, - ) -> TupleBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.remote_port(::planus::DefaultValue) - } - } - - impl TupleBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`protocol` field](Tuple#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol(self, value: T4) -> TupleBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - TupleBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`protocol` field](Tuple#structfield.protocol) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol_as_default( - self, - ) -> TupleBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.protocol(::planus::DefaultValue) - } - } - - impl TupleBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Tuple]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for TupleBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for TupleBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for TupleBuilder<(T0, T1, T2, T3, T4)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4) = &self.0; - Tuple::create(builder, v0, v1, v2, v3, v4) - } - } - - /// Reference to a deserialized [Tuple]. - #[derive(Copy, Clone)] - pub struct TupleRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TupleRef<'a> { - /// Getter for the [`local_ip` field](Tuple#structfield.local_ip). - #[inline] - pub fn local_ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Tuple", "local_ip") - } - - /// Getter for the [`local_port` field](Tuple#structfield.local_port). - #[inline] - pub fn local_port(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "Tuple", "local_port")?.unwrap_or(0), - ) - } - - /// Getter for the [`remote_ip` field](Tuple#structfield.remote_ip). - #[inline] - pub fn remote_ip( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(2, "Tuple", "remote_ip") - } - - /// Getter for the [`remote_port` field](Tuple#structfield.remote_port). - #[inline] - pub fn remote_port(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "Tuple", "remote_port")?.unwrap_or(0), - ) - } - - /// Getter for the [`protocol` field](Tuple#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "Tuple", "protocol")? - .unwrap_or(self::Protocol::Udp), - ) - } - } - - impl<'a> ::core::fmt::Debug for TupleRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("TupleRef"); - f.field("local_ip", &self.local_ip()); - f.field("local_port", &self.local_port()); - if let ::core::option::Option::Some(field_remote_ip) = - self.remote_ip().transpose() - { - f.field("remote_ip", &field_remote_ip); - } - f.field("remote_port", &self.remote_port()); - f.field("protocol", &self.protocol()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Tuple { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: TupleRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - local_ip: ::core::convert::TryInto::try_into(value.local_ip()?)?, - local_port: ::core::convert::TryInto::try_into(value.local_port()?)?, - remote_ip: if let ::core::option::Option::Some(remote_ip) = - value.remote_ip()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - remote_ip, - )?) - } else { - ::core::option::Option::None - }, - remote_port: ::core::convert::TryInto::try_into(value.remote_port()?)?, - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for TupleRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for TupleRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[TupleRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Tuple { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for TupleRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[TupleRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpListener` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:91` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtpListener { - /// The field `ssrc_table` in the table `RtpListener` - pub ssrc_table: ::planus::alloc::vec::Vec, - /// The field `mid_table` in the table `RtpListener` - pub mid_table: ::planus::alloc::vec::Vec, - /// The field `rid_table` in the table `RtpListener` - pub rid_table: ::planus::alloc::vec::Vec, - } - - impl RtpListener { - /// Creates a [RtpListenerBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpListenerBuilder<()> { - RtpListenerBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc_table: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_mid_table: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_rid_table: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_ssrc_table = field_ssrc_table.prepare(builder); - let prepared_mid_table = field_mid_table.prepare(builder); - let prepared_rid_table = field_rid_table.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(2); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_ssrc_table); - object_writer.write::<_, _, 4>(&prepared_mid_table); - object_writer.write::<_, _, 4>(&prepared_rid_table); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpListener { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpListener { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpListener { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpListener::create(builder, &self.ssrc_table, &self.mid_table, &self.rid_table) - } - } - - /// Builder for serializing an instance of the [RtpListener] type. - /// - /// Can be created using the [RtpListener::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpListenerBuilder(State); - - impl RtpListenerBuilder<()> { - /// Setter for the [`ssrc_table` field](RtpListener#structfield.ssrc_table). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_table(self, value: T0) -> RtpListenerBuilder<(T0,)> - where - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - RtpListenerBuilder((value,)) - } - } - - impl RtpListenerBuilder<(T0,)> { - /// Setter for the [`mid_table` field](RtpListener#structfield.mid_table). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid_table(self, value: T1) -> RtpListenerBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0,) = self.0; - RtpListenerBuilder((v0, value)) - } - } - - impl RtpListenerBuilder<(T0, T1)> { - /// Setter for the [`rid_table` field](RtpListener#structfield.rid_table). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_table(self, value: T2) -> RtpListenerBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1) = self.0; - RtpListenerBuilder((v0, v1, value)) - } - } - - impl RtpListenerBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpListener]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for RtpListenerBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpListenerBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T2: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset for RtpListenerBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - RtpListener::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [RtpListener]. - #[derive(Copy, Clone)] - pub struct RtpListenerRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpListenerRef<'a> { - /// Getter for the [`ssrc_table` field](RtpListener#structfield.ssrc_table). - #[inline] - pub fn ssrc_table( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "RtpListener", "ssrc_table") - } - - /// Getter for the [`mid_table` field](RtpListener#structfield.mid_table). - #[inline] - pub fn mid_table( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(1, "RtpListener", "mid_table") - } - - /// Getter for the [`rid_table` field](RtpListener#structfield.rid_table). - #[inline] - pub fn rid_table( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(2, "RtpListener", "rid_table") - } - } - - impl<'a> ::core::fmt::Debug for RtpListenerRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpListenerRef"); - f.field("ssrc_table", &self.ssrc_table()); - f.field("mid_table", &self.mid_table()); - f.field("rid_table", &self.rid_table()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpListener { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpListenerRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc_table: value.ssrc_table()?.to_vec_result()?, - mid_table: value.mid_table()?.to_vec_result()?, - rid_table: value.rid_table()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpListenerRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpListenerRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpListenerRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpListener { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpListenerRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpListenerRef]", "read_as_root", 0) - }) - } - } - - /// The table `SctpListener` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:97` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SctpListener { - /// The field `stream_id_table` in the table `SctpListener` - pub stream_id_table: ::planus::alloc::vec::Vec, - } - - impl SctpListener { - /// Creates a [SctpListenerBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SctpListenerBuilder<()> { - SctpListenerBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_stream_id_table: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_stream_id_table = field_stream_id_table.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_stream_id_table); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SctpListener { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SctpListener { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SctpListener { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SctpListener::create(builder, &self.stream_id_table) - } - } - - /// Builder for serializing an instance of the [SctpListener] type. - /// - /// Can be created using the [SctpListener::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SctpListenerBuilder(State); - - impl SctpListenerBuilder<()> { - /// Setter for the [`stream_id_table` field](SctpListener#structfield.stream_id_table). - #[inline] - #[allow(clippy::type_complexity)] - pub fn stream_id_table(self, value: T0) -> SctpListenerBuilder<(T0,)> - where - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - SctpListenerBuilder((value,)) - } - } - - impl SctpListenerBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SctpListener]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> for SctpListenerBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for SctpListenerBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset for SctpListenerBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SctpListener::create(builder, v0) - } - } - - /// Reference to a deserialized [SctpListener]. - #[derive(Copy, Clone)] - pub struct SctpListenerRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SctpListenerRef<'a> { - /// Getter for the [`stream_id_table` field](SctpListener#structfield.stream_id_table). - #[inline] - pub fn stream_id_table( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "SctpListener", "stream_id_table") - } - } - - impl<'a> ::core::fmt::Debug for SctpListenerRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SctpListenerRef"); - f.field("stream_id_table", &self.stream_id_table()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SctpListener { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SctpListenerRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - stream_id_table: value.stream_id_table()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SctpListenerRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SctpListenerRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SctpListenerRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SctpListener { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SctpListenerRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SctpListenerRef]", "read_as_root", 0) - }) - } - } - - /// The table `RecvRtpHeaderExtensions` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:101` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RecvRtpHeaderExtensions { - /// The field `mid` in the table `RecvRtpHeaderExtensions` - pub mid: ::core::option::Option, - /// The field `rid` in the table `RecvRtpHeaderExtensions` - pub rid: ::core::option::Option, - /// The field `rrid` in the table `RecvRtpHeaderExtensions` - pub rrid: ::core::option::Option, - /// The field `abs_send_time` in the table `RecvRtpHeaderExtensions` - pub abs_send_time: ::core::option::Option, - /// The field `transport_wide_cc01` in the table `RecvRtpHeaderExtensions` - pub transport_wide_cc01: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RecvRtpHeaderExtensions { - fn default() -> Self { - Self { - mid: ::core::default::Default::default(), - rid: ::core::default::Default::default(), - rrid: ::core::default::Default::default(), - abs_send_time: ::core::default::Default::default(), - transport_wide_cc01: ::core::default::Default::default(), - } - } - } - - impl RecvRtpHeaderExtensions { - /// Creates a [RecvRtpHeaderExtensionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RecvRtpHeaderExtensionsBuilder<()> { - RecvRtpHeaderExtensionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_mid: impl ::planus::WriteAsOptional, - field_rid: impl ::planus::WriteAsOptional, - field_rrid: impl ::planus::WriteAsOptional, - field_abs_send_time: impl ::planus::WriteAsOptional, - field_transport_wide_cc01: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_mid = field_mid.prepare(builder); - let prepared_rid = field_rid.prepare(builder); - let prepared_rrid = field_rrid.prepare(builder); - let prepared_abs_send_time = field_abs_send_time.prepare(builder); - let prepared_transport_wide_cc01 = field_transport_wide_cc01.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - if prepared_mid.is_some() { - table_writer.write_entry::(0); - } - if prepared_rid.is_some() { - table_writer.write_entry::(1); - } - if prepared_rrid.is_some() { - table_writer.write_entry::(2); - } - if prepared_abs_send_time.is_some() { - table_writer.write_entry::(3); - } - if prepared_transport_wide_cc01.is_some() { - table_writer.write_entry::(4); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_mid) = prepared_mid { - object_writer.write::<_, _, 1>(&prepared_mid); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 1>(&prepared_rid); - } - if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { - object_writer.write::<_, _, 1>(&prepared_rrid); - } - if let ::core::option::Option::Some(prepared_abs_send_time) = - prepared_abs_send_time - { - object_writer.write::<_, _, 1>(&prepared_abs_send_time); - } - if let ::core::option::Option::Some(prepared_transport_wide_cc01) = - prepared_transport_wide_cc01 - { - object_writer.write::<_, _, 1>(&prepared_transport_wide_cc01); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RecvRtpHeaderExtensions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for RecvRtpHeaderExtensions - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RecvRtpHeaderExtensions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RecvRtpHeaderExtensions::create( - builder, - self.mid, - self.rid, - self.rrid, - self.abs_send_time, - self.transport_wide_cc01, - ) - } - } - - /// Builder for serializing an instance of the [RecvRtpHeaderExtensions] type. - /// - /// Can be created using the [RecvRtpHeaderExtensions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RecvRtpHeaderExtensionsBuilder(State); - - impl RecvRtpHeaderExtensionsBuilder<()> { - /// Setter for the [`mid` field](RecvRtpHeaderExtensions#structfield.mid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid(self, value: T0) -> RecvRtpHeaderExtensionsBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional, - { - RecvRtpHeaderExtensionsBuilder((value,)) - } - - /// Sets the [`mid` field](RecvRtpHeaderExtensions#structfield.mid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn mid_as_null(self) -> RecvRtpHeaderExtensionsBuilder<((),)> { - self.mid(()) - } - } - - impl RecvRtpHeaderExtensionsBuilder<(T0,)> { - /// Setter for the [`rid` field](RecvRtpHeaderExtensions#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid(self, value: T1) -> RecvRtpHeaderExtensionsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - RecvRtpHeaderExtensionsBuilder((v0, value)) - } - - /// Sets the [`rid` field](RecvRtpHeaderExtensions#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> RecvRtpHeaderExtensionsBuilder<(T0, ())> { - self.rid(()) - } - } - - impl RecvRtpHeaderExtensionsBuilder<(T0, T1)> { - /// Setter for the [`rrid` field](RecvRtpHeaderExtensions#structfield.rrid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rrid(self, value: T2) -> RecvRtpHeaderExtensionsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - RecvRtpHeaderExtensionsBuilder((v0, v1, value)) - } - - /// Sets the [`rrid` field](RecvRtpHeaderExtensions#structfield.rrid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rrid_as_null(self) -> RecvRtpHeaderExtensionsBuilder<(T0, T1, ())> { - self.rrid(()) - } - } - - impl RecvRtpHeaderExtensionsBuilder<(T0, T1, T2)> { - /// Setter for the [`abs_send_time` field](RecvRtpHeaderExtensions#structfield.abs_send_time). - #[inline] - #[allow(clippy::type_complexity)] - pub fn abs_send_time( - self, - value: T3, - ) -> RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional, - { - let (v0, v1, v2) = self.0; - RecvRtpHeaderExtensionsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`abs_send_time` field](RecvRtpHeaderExtensions#structfield.abs_send_time) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn abs_send_time_as_null( - self, - ) -> RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, ())> { - self.abs_send_time(()) - } - } - - impl RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`transport_wide_cc01` field](RecvRtpHeaderExtensions#structfield.transport_wide_cc01). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_wide_cc01( - self, - value: T4, - ) -> RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3) = self.0; - RecvRtpHeaderExtensionsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`transport_wide_cc01` field](RecvRtpHeaderExtensions#structfield.transport_wide_cc01) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_wide_cc01_as_null( - self, - ) -> RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3, ())> { - self.transport_wide_cc01(()) - } - } - - impl RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RecvRtpHeaderExtensions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - T4: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for RecvRtpHeaderExtensionsBuilder<(T0, T1, T2, T3, T4)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4) = &self.0; - RecvRtpHeaderExtensions::create(builder, v0, v1, v2, v3, v4) - } - } - - /// Reference to a deserialized [RecvRtpHeaderExtensions]. - #[derive(Copy, Clone)] - pub struct RecvRtpHeaderExtensionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RecvRtpHeaderExtensionsRef<'a> { - /// Getter for the [`mid` field](RecvRtpHeaderExtensions#structfield.mid). - #[inline] - pub fn mid(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(0, "RecvRtpHeaderExtensions", "mid") - } - - /// Getter for the [`rid` field](RecvRtpHeaderExtensions#structfield.rid). - #[inline] - pub fn rid(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "RecvRtpHeaderExtensions", "rid") - } - - /// Getter for the [`rrid` field](RecvRtpHeaderExtensions#structfield.rrid). - #[inline] - pub fn rrid(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(2, "RecvRtpHeaderExtensions", "rrid") - } - - /// Getter for the [`abs_send_time` field](RecvRtpHeaderExtensions#structfield.abs_send_time). - #[inline] - pub fn abs_send_time(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(3, "RecvRtpHeaderExtensions", "abs_send_time") - } - - /// Getter for the [`transport_wide_cc01` field](RecvRtpHeaderExtensions#structfield.transport_wide_cc01). - #[inline] - pub fn transport_wide_cc01(&self) -> ::planus::Result<::core::option::Option> { - self.0 - .access(4, "RecvRtpHeaderExtensions", "transport_wide_cc01") - } - } - - impl<'a> ::core::fmt::Debug for RecvRtpHeaderExtensionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RecvRtpHeaderExtensionsRef"); - if let ::core::option::Option::Some(field_mid) = self.mid().transpose() { - f.field("mid", &field_mid); - } - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - if let ::core::option::Option::Some(field_rrid) = self.rrid().transpose() { - f.field("rrid", &field_rrid); - } - if let ::core::option::Option::Some(field_abs_send_time) = - self.abs_send_time().transpose() - { - f.field("abs_send_time", &field_abs_send_time); - } - if let ::core::option::Option::Some(field_transport_wide_cc01) = - self.transport_wide_cc01().transpose() - { - f.field("transport_wide_cc01", &field_transport_wide_cc01); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RecvRtpHeaderExtensions { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RecvRtpHeaderExtensionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - mid: if let ::core::option::Option::Some(mid) = value.mid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(mid)?) - } else { - ::core::option::Option::None - }, - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - rrid: if let ::core::option::Option::Some(rrid) = value.rrid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rrid)?) - } else { - ::core::option::Option::None - }, - abs_send_time: if let ::core::option::Option::Some(abs_send_time) = - value.abs_send_time()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - abs_send_time, - )?) - } else { - ::core::option::Option::None - }, - transport_wide_cc01: if let ::core::option::Option::Some( - transport_wide_cc01, - ) = value.transport_wide_cc01()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - transport_wide_cc01, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RecvRtpHeaderExtensionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RecvRtpHeaderExtensionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RecvRtpHeaderExtensionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RecvRtpHeaderExtensions { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RecvRtpHeaderExtensionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[RecvRtpHeaderExtensionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `Options` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `Options` in the file `../worker/fbs/transport.fbs:109` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Options { - /// The field `direct` in the table `Options` - pub direct: bool, - /// Only needed for DirectTransport. This value is handled by base Transport. - pub max_message_size: ::core::option::Option, - /// The field `initial_available_outgoing_bitrate` in the table `Options` - pub initial_available_outgoing_bitrate: ::core::option::Option, - /// The field `enable_sctp` in the table `Options` - pub enable_sctp: bool, - /// The field `num_sctp_streams` in the table `Options` - pub num_sctp_streams: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `max_sctp_message_size` in the table `Options` - pub max_sctp_message_size: u32, - /// The field `sctp_send_buffer_size` in the table `Options` - pub sctp_send_buffer_size: u32, - /// The field `is_data_channel` in the table `Options` - pub is_data_channel: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Options { - fn default() -> Self { - Self { - direct: false, - max_message_size: ::core::default::Default::default(), - initial_available_outgoing_bitrate: ::core::default::Default::default(), - enable_sctp: false, - num_sctp_streams: ::core::default::Default::default(), - max_sctp_message_size: 0, - sctp_send_buffer_size: 0, - is_data_channel: false, - } - } - } - - impl Options { - /// Creates a [OptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> OptionsBuilder<()> { - OptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_direct: impl ::planus::WriteAsDefault, - field_max_message_size: impl ::planus::WriteAsOptional, - field_initial_available_outgoing_bitrate: impl ::planus::WriteAsOptional, - field_enable_sctp: impl ::planus::WriteAsDefault, - field_num_sctp_streams: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_max_sctp_message_size: impl ::planus::WriteAsDefault, - field_sctp_send_buffer_size: impl ::planus::WriteAsDefault, - field_is_data_channel: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_direct = field_direct.prepare(builder, &false); - let prepared_max_message_size = field_max_message_size.prepare(builder); - let prepared_initial_available_outgoing_bitrate = - field_initial_available_outgoing_bitrate.prepare(builder); - let prepared_enable_sctp = field_enable_sctp.prepare(builder, &false); - let prepared_num_sctp_streams = field_num_sctp_streams.prepare(builder); - let prepared_max_sctp_message_size = - field_max_sctp_message_size.prepare(builder, &0); - let prepared_sctp_send_buffer_size = - field_sctp_send_buffer_size.prepare(builder, &0); - let prepared_is_data_channel = field_is_data_channel.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - if prepared_max_message_size.is_some() { - table_writer.write_entry::(1); - } - if prepared_initial_available_outgoing_bitrate.is_some() { - table_writer.write_entry::(2); - } - if prepared_num_sctp_streams.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_max_sctp_message_size.is_some() { - table_writer.write_entry::(5); - } - if prepared_sctp_send_buffer_size.is_some() { - table_writer.write_entry::(6); - } - if prepared_direct.is_some() { - table_writer.write_entry::(0); - } - if prepared_enable_sctp.is_some() { - table_writer.write_entry::(3); - } - if prepared_is_data_channel.is_some() { - table_writer.write_entry::(7); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_max_message_size) = - prepared_max_message_size - { - object_writer.write::<_, _, 4>(&prepared_max_message_size); - } - if let ::core::option::Option::Some( - prepared_initial_available_outgoing_bitrate, - ) = prepared_initial_available_outgoing_bitrate - { - object_writer - .write::<_, _, 4>(&prepared_initial_available_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_num_sctp_streams) = - prepared_num_sctp_streams - { - object_writer.write::<_, _, 4>(&prepared_num_sctp_streams); - } - if let ::core::option::Option::Some(prepared_max_sctp_message_size) = - prepared_max_sctp_message_size - { - object_writer.write::<_, _, 4>(&prepared_max_sctp_message_size); - } - if let ::core::option::Option::Some(prepared_sctp_send_buffer_size) = - prepared_sctp_send_buffer_size - { - object_writer.write::<_, _, 4>(&prepared_sctp_send_buffer_size); - } - if let ::core::option::Option::Some(prepared_direct) = prepared_direct { - object_writer.write::<_, _, 1>(&prepared_direct); - } - if let ::core::option::Option::Some(prepared_enable_sctp) = - prepared_enable_sctp - { - object_writer.write::<_, _, 1>(&prepared_enable_sctp); - } - if let ::core::option::Option::Some(prepared_is_data_channel) = - prepared_is_data_channel - { - object_writer.write::<_, _, 1>(&prepared_is_data_channel); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Options { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Options { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Options { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Options::create( - builder, - self.direct, - self.max_message_size, - self.initial_available_outgoing_bitrate, - self.enable_sctp, - &self.num_sctp_streams, - self.max_sctp_message_size, - self.sctp_send_buffer_size, - self.is_data_channel, - ) - } - } - - /// Builder for serializing an instance of the [Options] type. - /// - /// Can be created using the [Options::builder] method. - #[derive(Debug)] - #[must_use] - pub struct OptionsBuilder(State); - - impl OptionsBuilder<()> { - /// Setter for the [`direct` field](Options#structfield.direct). - #[inline] - #[allow(clippy::type_complexity)] - pub fn direct(self, value: T0) -> OptionsBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - OptionsBuilder((value,)) - } - - /// Sets the [`direct` field](Options#structfield.direct) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn direct_as_default(self) -> OptionsBuilder<(::planus::DefaultValue,)> { - self.direct(::planus::DefaultValue) - } - } - - impl OptionsBuilder<(T0,)> { - /// Setter for the [`max_message_size` field](Options#structfield.max_message_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_message_size(self, value: T1) -> OptionsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - OptionsBuilder((v0, value)) - } - - /// Sets the [`max_message_size` field](Options#structfield.max_message_size) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_message_size_as_null(self) -> OptionsBuilder<(T0, ())> { - self.max_message_size(()) - } - } - - impl OptionsBuilder<(T0, T1)> { - /// Setter for the [`initial_available_outgoing_bitrate` field](Options#structfield.initial_available_outgoing_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn initial_available_outgoing_bitrate( - self, - value: T2, - ) -> OptionsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - OptionsBuilder((v0, v1, value)) - } - - /// Sets the [`initial_available_outgoing_bitrate` field](Options#structfield.initial_available_outgoing_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn initial_available_outgoing_bitrate_as_null( - self, - ) -> OptionsBuilder<(T0, T1, ())> { - self.initial_available_outgoing_bitrate(()) - } - } - - impl OptionsBuilder<(T0, T1, T2)> { - /// Setter for the [`enable_sctp` field](Options#structfield.enable_sctp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_sctp(self, value: T3) -> OptionsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - OptionsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`enable_sctp` field](Options#structfield.enable_sctp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_sctp_as_default( - self, - ) -> OptionsBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.enable_sctp(::planus::DefaultValue) - } - } - - impl OptionsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`num_sctp_streams` field](Options#structfield.num_sctp_streams). - #[inline] - #[allow(clippy::type_complexity)] - pub fn num_sctp_streams(self, value: T4) -> OptionsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2, v3) = self.0; - OptionsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`num_sctp_streams` field](Options#structfield.num_sctp_streams) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn num_sctp_streams_as_null(self) -> OptionsBuilder<(T0, T1, T2, T3, ())> { - self.num_sctp_streams(()) - } - } - - impl OptionsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`max_sctp_message_size` field](Options#structfield.max_sctp_message_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_sctp_message_size( - self, - value: T5, - ) -> OptionsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - OptionsBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`max_sctp_message_size` field](Options#structfield.max_sctp_message_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_sctp_message_size_as_default( - self, - ) -> OptionsBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> { - self.max_sctp_message_size(::planus::DefaultValue) - } - } - - impl OptionsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`sctp_send_buffer_size` field](Options#structfield.sctp_send_buffer_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_send_buffer_size( - self, - value: T6, - ) -> OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - OptionsBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`sctp_send_buffer_size` field](Options#structfield.sctp_send_buffer_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_send_buffer_size_as_default( - self, - ) -> OptionsBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.sctp_send_buffer_size(::planus::DefaultValue) - } - } - - impl OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`is_data_channel` field](Options#structfield.is_data_channel). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_data_channel( - self, - value: T7, - ) -> OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - OptionsBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`is_data_channel` field](Options#structfield.is_data_channel) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_data_channel_as_default( - self, - ) -> OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.is_data_channel(::planus::DefaultValue) - } - } - - impl OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Options]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for OptionsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - Options::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [Options]. - #[derive(Copy, Clone)] - pub struct OptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> OptionsRef<'a> { - /// Getter for the [`direct` field](Options#structfield.direct). - #[inline] - pub fn direct(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "Options", "direct")?.unwrap_or(false), - ) - } - - /// Getter for the [`max_message_size` field](Options#structfield.max_message_size). - #[inline] - pub fn max_message_size(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "Options", "max_message_size") - } - - /// Getter for the [`initial_available_outgoing_bitrate` field](Options#structfield.initial_available_outgoing_bitrate). - #[inline] - pub fn initial_available_outgoing_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0 - .access(2, "Options", "initial_available_outgoing_bitrate") - } - - /// Getter for the [`enable_sctp` field](Options#structfield.enable_sctp). - #[inline] - pub fn enable_sctp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "Options", "enable_sctp")?.unwrap_or(false), - ) - } - - /// Getter for the [`num_sctp_streams` field](Options#structfield.num_sctp_streams). - #[inline] - pub fn num_sctp_streams( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(4, "Options", "num_sctp_streams") - } - - /// Getter for the [`max_sctp_message_size` field](Options#structfield.max_sctp_message_size). - #[inline] - pub fn max_sctp_message_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "Options", "max_sctp_message_size")? - .unwrap_or(0), - ) - } - - /// Getter for the [`sctp_send_buffer_size` field](Options#structfield.sctp_send_buffer_size). - #[inline] - pub fn sctp_send_buffer_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "Options", "sctp_send_buffer_size")? - .unwrap_or(0), - ) - } - - /// Getter for the [`is_data_channel` field](Options#structfield.is_data_channel). - #[inline] - pub fn is_data_channel(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "Options", "is_data_channel")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for OptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("OptionsRef"); - f.field("direct", &self.direct()); - if let ::core::option::Option::Some(field_max_message_size) = - self.max_message_size().transpose() - { - f.field("max_message_size", &field_max_message_size); - } - if let ::core::option::Option::Some(field_initial_available_outgoing_bitrate) = - self.initial_available_outgoing_bitrate().transpose() - { - f.field( - "initial_available_outgoing_bitrate", - &field_initial_available_outgoing_bitrate, - ); - } - f.field("enable_sctp", &self.enable_sctp()); - if let ::core::option::Option::Some(field_num_sctp_streams) = - self.num_sctp_streams().transpose() - { - f.field("num_sctp_streams", &field_num_sctp_streams); - } - f.field("max_sctp_message_size", &self.max_sctp_message_size()); - f.field("sctp_send_buffer_size", &self.sctp_send_buffer_size()); - f.field("is_data_channel", &self.is_data_channel()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Options { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: OptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - direct: ::core::convert::TryInto::try_into(value.direct()?)?, - max_message_size: if let ::core::option::Option::Some(max_message_size) = - value.max_message_size()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - max_message_size, - )?) - } else { - ::core::option::Option::None - }, - initial_available_outgoing_bitrate: if let ::core::option::Option::Some( - initial_available_outgoing_bitrate, - ) = - value.initial_available_outgoing_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - initial_available_outgoing_bitrate, - )?) - } else { - ::core::option::Option::None - }, - enable_sctp: ::core::convert::TryInto::try_into(value.enable_sctp()?)?, - num_sctp_streams: if let ::core::option::Option::Some(num_sctp_streams) = - value.num_sctp_streams()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(num_sctp_streams)?, - )) - } else { - ::core::option::Option::None - }, - max_sctp_message_size: ::core::convert::TryInto::try_into( - value.max_sctp_message_size()?, - )?, - sctp_send_buffer_size: ::core::convert::TryInto::try_into( - value.sctp_send_buffer_size()?, - )?, - is_data_channel: ::core::convert::TryInto::try_into( - value.is_data_channel()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for OptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for OptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[OptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Options { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for OptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[OptionsRef]", "read_as_root", 0) - }) - } - } - - /// The enum `TraceEventType` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:122` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceEventType { - /// The variant `PROBATION` in the enum `TraceEventType` - Probation = 0, - - /// The variant `BWE` in the enum `TraceEventType` - Bwe = 1, - } - - impl TraceEventType { - /// Array containing all valid variants of TraceEventType - pub const ENUM_VALUES: [Self; 2] = [Self::Probation, Self::Bwe]; - } - - impl ::core::convert::TryFrom for TraceEventType { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(TraceEventType::Probation), - 1 => ::core::result::Result::Ok(TraceEventType::Bwe), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceEventType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceEventType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceEventType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceEventType { - *self - } - } - - impl ::planus::WriteAsDefault for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceEventType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for TraceEventType { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for TraceEventType { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "TraceEventType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for TraceEventType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `Dump` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:127` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Dump { - /// The field `id` in the table `Dump` - pub id: ::planus::alloc::string::String, - /// The field `direct` in the table `Dump` - pub direct: bool, - /// The field `producer_ids` in the table `Dump` - pub producer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `consumer_ids` in the table `Dump` - pub consumer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `map_ssrc_consumer_id` in the table `Dump` - pub map_ssrc_consumer_id: ::planus::alloc::vec::Vec, - /// The field `map_rtx_ssrc_consumer_id` in the table `Dump` - pub map_rtx_ssrc_consumer_id: - ::planus::alloc::vec::Vec, - /// The field `data_producer_ids` in the table `Dump` - pub data_producer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `data_consumer_ids` in the table `Dump` - pub data_consumer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `recv_rtp_header_extensions` in the table `Dump` - pub recv_rtp_header_extensions: - ::planus::alloc::boxed::Box, - /// The field `rtp_listener` in the table `Dump` - pub rtp_listener: ::planus::alloc::boxed::Box, - /// The field `max_message_size` in the table `Dump` - pub max_message_size: u32, - /// The field `sctp_parameters` in the table `Dump` - pub sctp_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `sctp_state` in the table `Dump` - pub sctp_state: ::core::option::Option, - /// The field `sctp_listener` in the table `Dump` - pub sctp_listener: - ::core::option::Option<::planus::alloc::boxed::Box>, - /// The field `trace_event_types` in the table `Dump` - pub trace_event_types: ::planus::alloc::vec::Vec, - } - - impl Dump { - /// Creates a [DumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpBuilder<()> { - DumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_direct: impl ::planus::WriteAsDefault, - field_producer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_consumer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_ssrc_consumer_id: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_rtx_ssrc_consumer_id: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_data_producer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_data_consumer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_recv_rtp_header_extensions: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtp_listener: impl ::planus::WriteAs<::planus::Offset>, - field_max_message_size: impl ::planus::WriteAsDefault, - field_sctp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_sctp_state: impl ::planus::WriteAsOptional, - field_sctp_listener: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[self::TraceEventType]>, - >, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_direct = field_direct.prepare(builder, &false); - let prepared_producer_ids = field_producer_ids.prepare(builder); - let prepared_consumer_ids = field_consumer_ids.prepare(builder); - let prepared_map_ssrc_consumer_id = field_map_ssrc_consumer_id.prepare(builder); - let prepared_map_rtx_ssrc_consumer_id = - field_map_rtx_ssrc_consumer_id.prepare(builder); - let prepared_data_producer_ids = field_data_producer_ids.prepare(builder); - let prepared_data_consumer_ids = field_data_consumer_ids.prepare(builder); - let prepared_recv_rtp_header_extensions = - field_recv_rtp_header_extensions.prepare(builder); - let prepared_rtp_listener = field_rtp_listener.prepare(builder); - let prepared_max_message_size = field_max_message_size.prepare(builder, &0); - let prepared_sctp_parameters = field_sctp_parameters.prepare(builder); - let prepared_sctp_state = field_sctp_state.prepare(builder); - let prepared_sctp_listener = field_sctp_listener.prepare(builder); - let prepared_trace_event_types = field_trace_event_types.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<34> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(2); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(3); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(4); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(6); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(7); - table_writer.write_entry::<::planus::Offset>(8); - table_writer.write_entry::<::planus::Offset>(9); - if prepared_max_message_size.is_some() { - table_writer.write_entry::(10); - } - if prepared_sctp_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(11); - } - if prepared_sctp_listener.is_some() { - table_writer.write_entry::<::planus::Offset>(13); - } - table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(14); - if prepared_direct.is_some() { - table_writer.write_entry::(1); - } - if prepared_sctp_state.is_some() { - table_writer.write_entry::(12); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_producer_ids); - object_writer.write::<_, _, 4>(&prepared_consumer_ids); - object_writer.write::<_, _, 4>(&prepared_map_ssrc_consumer_id); - object_writer.write::<_, _, 4>(&prepared_map_rtx_ssrc_consumer_id); - object_writer.write::<_, _, 4>(&prepared_data_producer_ids); - object_writer.write::<_, _, 4>(&prepared_data_consumer_ids); - object_writer.write::<_, _, 4>(&prepared_recv_rtp_header_extensions); - object_writer.write::<_, _, 4>(&prepared_rtp_listener); - if let ::core::option::Option::Some(prepared_max_message_size) = - prepared_max_message_size - { - object_writer.write::<_, _, 4>(&prepared_max_message_size); - } - if let ::core::option::Option::Some(prepared_sctp_parameters) = - prepared_sctp_parameters - { - object_writer.write::<_, _, 4>(&prepared_sctp_parameters); - } - if let ::core::option::Option::Some(prepared_sctp_listener) = - prepared_sctp_listener - { - object_writer.write::<_, _, 4>(&prepared_sctp_listener); - } - object_writer.write::<_, _, 4>(&prepared_trace_event_types); - if let ::core::option::Option::Some(prepared_direct) = prepared_direct { - object_writer.write::<_, _, 1>(&prepared_direct); - } - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - object_writer.write::<_, _, 1>(&prepared_sctp_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Dump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Dump { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Dump { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Dump::create( - builder, - &self.id, - self.direct, - &self.producer_ids, - &self.consumer_ids, - &self.map_ssrc_consumer_id, - &self.map_rtx_ssrc_consumer_id, - &self.data_producer_ids, - &self.data_consumer_ids, - &self.recv_rtp_header_extensions, - &self.rtp_listener, - self.max_message_size, - &self.sctp_parameters, - self.sctp_state, - &self.sctp_listener, - &self.trace_event_types, - ) - } - } - - /// Builder for serializing an instance of the [Dump] type. - /// - /// Can be created using the [Dump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpBuilder(State); - - impl DumpBuilder<()> { - /// Setter for the [`id` field](Dump#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpBuilder((value,)) - } - } - - impl DumpBuilder<(T0,)> { - /// Setter for the [`direct` field](Dump#structfield.direct). - #[inline] - #[allow(clippy::type_complexity)] - pub fn direct(self, value: T1) -> DumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DumpBuilder((v0, value)) - } - - /// Sets the [`direct` field](Dump#structfield.direct) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn direct_as_default(self) -> DumpBuilder<(T0, ::planus::DefaultValue)> { - self.direct(::planus::DefaultValue) - } - } - - impl DumpBuilder<(T0, T1)> { - /// Setter for the [`producer_ids` field](Dump#structfield.producer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_ids(self, value: T2) -> DumpBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1) = self.0; - DumpBuilder((v0, v1, value)) - } - } - - impl DumpBuilder<(T0, T1, T2)> { - /// Setter for the [`consumer_ids` field](Dump#structfield.consumer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn consumer_ids(self, value: T3) -> DumpBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1, v2) = self.0; - DumpBuilder((v0, v1, v2, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`map_ssrc_consumer_id` field](Dump#structfield.map_ssrc_consumer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_ssrc_consumer_id( - self, - value: T4, - ) -> DumpBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3) = self.0; - DumpBuilder((v0, v1, v2, v3, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`map_rtx_ssrc_consumer_id` field](Dump#structfield.map_rtx_ssrc_consumer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_rtx_ssrc_consumer_id( - self, - value: T5, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`data_producer_ids` field](Dump#structfield.data_producer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_ids( - self, - value: T6, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`data_consumer_ids` field](Dump#structfield.data_consumer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_consumer_ids( - self, - value: T7, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`recv_rtp_header_extensions` field](Dump#structfield.recv_rtp_header_extensions). - #[inline] - #[allow(clippy::type_complexity)] - pub fn recv_rtp_header_extensions( - self, - value: T8, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`rtp_listener` field](Dump#structfield.rtp_listener). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_listener( - self, - value: T9, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - } - - impl DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> { - /// Setter for the [`max_message_size` field](Dump#structfield.max_message_size). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_message_size( - self, - value: T10, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`max_message_size` field](Dump#structfield.max_message_size) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_message_size_as_default( - self, - ) -> DumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - ::planus::DefaultValue, - )> { - self.max_message_size(::planus::DefaultValue) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Setter for the [`sctp_parameters` field](Dump#structfield.sctp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_parameters( - self, - value: T11, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - where - T11: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, value)) - } - - /// Sets the [`sctp_parameters` field](Dump#structfield.sctp_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_parameters_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ())> - { - self.sctp_parameters(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`sctp_state` field](Dump#structfield.sctp_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_state( - self, - value: T12, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - where - T12: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, value)) - } - - /// Sets the [`sctp_state` field](Dump#structfield.sctp_state) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_state_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ())> - { - self.sctp_state(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - { - /// Setter for the [`sctp_listener` field](Dump#structfield.sctp_listener). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_listener( - self, - value: T13, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - where - T13: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) = self.0; - DumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, value)) - } - - /// Sets the [`sctp_listener` field](Dump#structfield.sctp_listener) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_listener_as_null( - self, - ) -> DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ())> - { - self.sctp_listener(()) - } - } - - impl - DumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - /// Setter for the [`trace_event_types` field](Dump#structfield.trace_event_types). - #[inline] - #[allow(clippy::type_complexity)] - pub fn trace_event_types( - self, - value: T14, - ) -> DumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - where - T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) = self.0; - DumpBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, value, - )) - } - } - - impl - DumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Dump]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T8: ::planus::WriteAs<::planus::Offset>, - T9: ::planus::WriteAs<::planus::Offset>, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T12: ::planus::WriteAsOptional, - T13: ::planus::WriteAsOptional<::planus::Offset>, - T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - > ::planus::WriteAs<::planus::Offset> - for DumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T8: ::planus::WriteAs<::planus::Offset>, - T9: ::planus::WriteAs<::planus::Offset>, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T12: ::planus::WriteAsOptional, - T13: ::planus::WriteAsOptional<::planus::Offset>, - T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T8: ::planus::WriteAs<::planus::Offset>, - T9: ::planus::WriteAs<::planus::Offset>, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsOptional< - ::planus::Offset, - >, - T12: ::planus::WriteAsOptional, - T13: ::planus::WriteAsOptional<::planus::Offset>, - T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - > ::planus::WriteAsOffset - for DumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) = &self.0; - Dump::create( - builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, - ) - } - } - - /// Reference to a deserialized [Dump]. - #[derive(Copy, Clone)] - pub struct DumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpRef<'a> { - /// Getter for the [`id` field](Dump#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Dump", "id") - } - - /// Getter for the [`direct` field](Dump#structfield.direct). - #[inline] - pub fn direct(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Dump", "direct")?.unwrap_or(false)) - } - - /// Getter for the [`producer_ids` field](Dump#structfield.producer_ids). - #[inline] - pub fn producer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(2, "Dump", "producer_ids") - } - - /// Getter for the [`consumer_ids` field](Dump#structfield.consumer_ids). - #[inline] - pub fn consumer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(3, "Dump", "consumer_ids") - } - - /// Getter for the [`map_ssrc_consumer_id` field](Dump#structfield.map_ssrc_consumer_id). - #[inline] - pub fn map_ssrc_consumer_id( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(4, "Dump", "map_ssrc_consumer_id") - } - - /// Getter for the [`map_rtx_ssrc_consumer_id` field](Dump#structfield.map_rtx_ssrc_consumer_id). - #[inline] - pub fn map_rtx_ssrc_consumer_id( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(5, "Dump", "map_rtx_ssrc_consumer_id") - } - - /// Getter for the [`data_producer_ids` field](Dump#structfield.data_producer_ids). - #[inline] - pub fn data_producer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(6, "Dump", "data_producer_ids") - } - - /// Getter for the [`data_consumer_ids` field](Dump#structfield.data_consumer_ids). - #[inline] - pub fn data_consumer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(7, "Dump", "data_consumer_ids") - } - - /// Getter for the [`recv_rtp_header_extensions` field](Dump#structfield.recv_rtp_header_extensions). - #[inline] - pub fn recv_rtp_header_extensions( - &self, - ) -> ::planus::Result> { - self.0 - .access_required(8, "Dump", "recv_rtp_header_extensions") - } - - /// Getter for the [`rtp_listener` field](Dump#structfield.rtp_listener). - #[inline] - pub fn rtp_listener(&self) -> ::planus::Result> { - self.0.access_required(9, "Dump", "rtp_listener") - } - - /// Getter for the [`max_message_size` field](Dump#structfield.max_message_size). - #[inline] - pub fn max_message_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(10, "Dump", "max_message_size")?.unwrap_or(0), - ) - } - - /// Getter for the [`sctp_parameters` field](Dump#structfield.sctp_parameters). - #[inline] - pub fn sctp_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(11, "Dump", "sctp_parameters") - } - - /// Getter for the [`sctp_state` field](Dump#structfield.sctp_state). - #[inline] - pub fn sctp_state( - &self, - ) -> ::planus::Result<::core::option::Option> - { - self.0.access(12, "Dump", "sctp_state") - } - - /// Getter for the [`sctp_listener` field](Dump#structfield.sctp_listener). - #[inline] - pub fn sctp_listener( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(13, "Dump", "sctp_listener") - } - - /// Getter for the [`trace_event_types` field](Dump#structfield.trace_event_types). - #[inline] - pub fn trace_event_types( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::core::result::Result< - self::TraceEventType, - ::planus::errors::UnknownEnumTag, - >, - >, - > { - self.0.access_required(14, "Dump", "trace_event_types") - } - } - - impl<'a> ::core::fmt::Debug for DumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpRef"); - f.field("id", &self.id()); - f.field("direct", &self.direct()); - f.field("producer_ids", &self.producer_ids()); - f.field("consumer_ids", &self.consumer_ids()); - f.field("map_ssrc_consumer_id", &self.map_ssrc_consumer_id()); - f.field("map_rtx_ssrc_consumer_id", &self.map_rtx_ssrc_consumer_id()); - f.field("data_producer_ids", &self.data_producer_ids()); - f.field("data_consumer_ids", &self.data_consumer_ids()); - f.field( - "recv_rtp_header_extensions", - &self.recv_rtp_header_extensions(), - ); - f.field("rtp_listener", &self.rtp_listener()); - f.field("max_message_size", &self.max_message_size()); - if let ::core::option::Option::Some(field_sctp_parameters) = - self.sctp_parameters().transpose() - { - f.field("sctp_parameters", &field_sctp_parameters); - } - if let ::core::option::Option::Some(field_sctp_state) = - self.sctp_state().transpose() - { - f.field("sctp_state", &field_sctp_state); - } - if let ::core::option::Option::Some(field_sctp_listener) = - self.sctp_listener().transpose() - { - f.field("sctp_listener", &field_sctp_listener); - } - f.field("trace_event_types", &self.trace_event_types()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Dump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - direct: ::core::convert::TryInto::try_into(value.direct()?)?, - producer_ids: value.producer_ids()?.to_vec_result()?, - consumer_ids: value.consumer_ids()?.to_vec_result()?, - map_ssrc_consumer_id: value.map_ssrc_consumer_id()?.to_vec_result()?, - map_rtx_ssrc_consumer_id: value - .map_rtx_ssrc_consumer_id()? - .to_vec_result()?, - data_producer_ids: value.data_producer_ids()?.to_vec_result()?, - data_consumer_ids: value.data_consumer_ids()?.to_vec_result()?, - recv_rtp_header_extensions: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into( - value.recv_rtp_header_extensions()?, - )?, - ), - rtp_listener: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_listener()?)?, - ), - max_message_size: ::core::convert::TryInto::try_into( - value.max_message_size()?, - )?, - sctp_parameters: if let ::core::option::Option::Some(sctp_parameters) = - value.sctp_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(sctp_parameters)?, - )) - } else { - ::core::option::Option::None - }, - sctp_state: if let ::core::option::Option::Some(sctp_state) = - value.sctp_state()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - sctp_state, - )?) - } else { - ::core::option::Option::None - }, - sctp_listener: if let ::core::option::Option::Some(sctp_listener) = - value.sctp_listener()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(sctp_listener)?, - )) - } else { - ::core::option::Option::None - }, - trace_event_types: value.trace_event_types()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location("[DumpRef]", "get", buffer.offset_from_start) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Dump { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpRef]", "read_as_root", 0) - }) - } - } - - /// The table `Stats` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:145` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Stats { - /// The field `transport_id` in the table `Stats` - pub transport_id: ::planus::alloc::string::String, - /// The field `timestamp` in the table `Stats` - pub timestamp: u64, - /// The field `sctp_state` in the table `Stats` - pub sctp_state: ::core::option::Option, - /// The field `bytes_received` in the table `Stats` - pub bytes_received: u64, - /// The field `recv_bitrate` in the table `Stats` - pub recv_bitrate: u32, - /// The field `bytes_sent` in the table `Stats` - pub bytes_sent: u64, - /// The field `send_bitrate` in the table `Stats` - pub send_bitrate: u32, - /// The field `rtp_bytes_received` in the table `Stats` - pub rtp_bytes_received: u64, - /// The field `rtp_recv_bitrate` in the table `Stats` - pub rtp_recv_bitrate: u32, - /// The field `rtp_bytes_sent` in the table `Stats` - pub rtp_bytes_sent: u64, - /// The field `rtp_send_bitrate` in the table `Stats` - pub rtp_send_bitrate: u32, - /// The field `rtx_bytes_received` in the table `Stats` - pub rtx_bytes_received: u64, - /// The field `rtx_recv_bitrate` in the table `Stats` - pub rtx_recv_bitrate: u32, - /// The field `rtx_bytes_sent` in the table `Stats` - pub rtx_bytes_sent: u64, - /// The field `rtx_send_bitrate` in the table `Stats` - pub rtx_send_bitrate: u32, - /// The field `probation_bytes_sent` in the table `Stats` - pub probation_bytes_sent: u64, - /// The field `probation_send_bitrate` in the table `Stats` - pub probation_send_bitrate: u32, - /// The field `available_outgoing_bitrate` in the table `Stats` - pub available_outgoing_bitrate: ::core::option::Option, - /// The field `available_incoming_bitrate` in the table `Stats` - pub available_incoming_bitrate: ::core::option::Option, - /// The field `max_incoming_bitrate` in the table `Stats` - pub max_incoming_bitrate: ::core::option::Option, - /// The field `max_outgoing_bitrate` in the table `Stats` - pub max_outgoing_bitrate: ::core::option::Option, - /// The field `min_outgoing_bitrate` in the table `Stats` - pub min_outgoing_bitrate: ::core::option::Option, - /// The field `rtp_packet_loss_received` in the table `Stats` - pub rtp_packet_loss_received: ::core::option::Option, - /// The field `rtp_packet_loss_sent` in the table `Stats` - pub rtp_packet_loss_sent: ::core::option::Option, - } - - impl Stats { - /// Creates a [StatsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> StatsBuilder<()> { - StatsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, - field_timestamp: impl ::planus::WriteAsDefault, - field_sctp_state: impl ::planus::WriteAsOptional, - field_bytes_received: impl ::planus::WriteAsDefault, - field_recv_bitrate: impl ::planus::WriteAsDefault, - field_bytes_sent: impl ::planus::WriteAsDefault, - field_send_bitrate: impl ::planus::WriteAsDefault, - field_rtp_bytes_received: impl ::planus::WriteAsDefault, - field_rtp_recv_bitrate: impl ::planus::WriteAsDefault, - field_rtp_bytes_sent: impl ::planus::WriteAsDefault, - field_rtp_send_bitrate: impl ::planus::WriteAsDefault, - field_rtx_bytes_received: impl ::planus::WriteAsDefault, - field_rtx_recv_bitrate: impl ::planus::WriteAsDefault, - field_rtx_bytes_sent: impl ::planus::WriteAsDefault, - field_rtx_send_bitrate: impl ::planus::WriteAsDefault, - field_probation_bytes_sent: impl ::planus::WriteAsDefault, - field_probation_send_bitrate: impl ::planus::WriteAsDefault, - field_available_outgoing_bitrate: impl ::planus::WriteAsOptional, - field_available_incoming_bitrate: impl ::planus::WriteAsOptional, - field_max_incoming_bitrate: impl ::planus::WriteAsOptional, - field_max_outgoing_bitrate: impl ::planus::WriteAsOptional, - field_min_outgoing_bitrate: impl ::planus::WriteAsOptional, - field_rtp_packet_loss_received: impl ::planus::WriteAsOptional, - field_rtp_packet_loss_sent: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_sctp_state = field_sctp_state.prepare(builder); - let prepared_bytes_received = field_bytes_received.prepare(builder, &0); - let prepared_recv_bitrate = field_recv_bitrate.prepare(builder, &0); - let prepared_bytes_sent = field_bytes_sent.prepare(builder, &0); - let prepared_send_bitrate = field_send_bitrate.prepare(builder, &0); - let prepared_rtp_bytes_received = field_rtp_bytes_received.prepare(builder, &0); - let prepared_rtp_recv_bitrate = field_rtp_recv_bitrate.prepare(builder, &0); - let prepared_rtp_bytes_sent = field_rtp_bytes_sent.prepare(builder, &0); - let prepared_rtp_send_bitrate = field_rtp_send_bitrate.prepare(builder, &0); - let prepared_rtx_bytes_received = field_rtx_bytes_received.prepare(builder, &0); - let prepared_rtx_recv_bitrate = field_rtx_recv_bitrate.prepare(builder, &0); - let prepared_rtx_bytes_sent = field_rtx_bytes_sent.prepare(builder, &0); - let prepared_rtx_send_bitrate = field_rtx_send_bitrate.prepare(builder, &0); - let prepared_probation_bytes_sent = - field_probation_bytes_sent.prepare(builder, &0); - let prepared_probation_send_bitrate = - field_probation_send_bitrate.prepare(builder, &0); - let prepared_available_outgoing_bitrate = - field_available_outgoing_bitrate.prepare(builder); - let prepared_available_incoming_bitrate = - field_available_incoming_bitrate.prepare(builder); - let prepared_max_incoming_bitrate = field_max_incoming_bitrate.prepare(builder); - let prepared_max_outgoing_bitrate = field_max_outgoing_bitrate.prepare(builder); - let prepared_min_outgoing_bitrate = field_min_outgoing_bitrate.prepare(builder); - let prepared_rtp_packet_loss_received = - field_rtp_packet_loss_received.prepare(builder); - let prepared_rtp_packet_loss_sent = field_rtp_packet_loss_sent.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<52> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(1); - } - if prepared_bytes_received.is_some() { - table_writer.write_entry::(3); - } - if prepared_bytes_sent.is_some() { - table_writer.write_entry::(5); - } - if prepared_rtp_bytes_received.is_some() { - table_writer.write_entry::(7); - } - if prepared_rtp_bytes_sent.is_some() { - table_writer.write_entry::(9); - } - if prepared_rtx_bytes_received.is_some() { - table_writer.write_entry::(11); - } - if prepared_rtx_bytes_sent.is_some() { - table_writer.write_entry::(13); - } - if prepared_probation_bytes_sent.is_some() { - table_writer.write_entry::(15); - } - if prepared_rtp_packet_loss_received.is_some() { - table_writer.write_entry::(22); - } - if prepared_rtp_packet_loss_sent.is_some() { - table_writer.write_entry::(23); - } - table_writer.write_entry::<::planus::Offset>(0); - if prepared_recv_bitrate.is_some() { - table_writer.write_entry::(4); - } - if prepared_send_bitrate.is_some() { - table_writer.write_entry::(6); - } - if prepared_rtp_recv_bitrate.is_some() { - table_writer.write_entry::(8); - } - if prepared_rtp_send_bitrate.is_some() { - table_writer.write_entry::(10); - } - if prepared_rtx_recv_bitrate.is_some() { - table_writer.write_entry::(12); - } - if prepared_rtx_send_bitrate.is_some() { - table_writer.write_entry::(14); - } - if prepared_probation_send_bitrate.is_some() { - table_writer.write_entry::(16); - } - if prepared_available_outgoing_bitrate.is_some() { - table_writer.write_entry::(17); - } - if prepared_available_incoming_bitrate.is_some() { - table_writer.write_entry::(18); - } - if prepared_max_incoming_bitrate.is_some() { - table_writer.write_entry::(19); - } - if prepared_max_outgoing_bitrate.is_some() { - table_writer.write_entry::(20); - } - if prepared_min_outgoing_bitrate.is_some() { - table_writer.write_entry::(21); - } - if prepared_sctp_state.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_bytes_received) = - prepared_bytes_received - { - object_writer.write::<_, _, 8>(&prepared_bytes_received); - } - if let ::core::option::Option::Some(prepared_bytes_sent) = - prepared_bytes_sent - { - object_writer.write::<_, _, 8>(&prepared_bytes_sent); - } - if let ::core::option::Option::Some(prepared_rtp_bytes_received) = - prepared_rtp_bytes_received - { - object_writer.write::<_, _, 8>(&prepared_rtp_bytes_received); - } - if let ::core::option::Option::Some(prepared_rtp_bytes_sent) = - prepared_rtp_bytes_sent - { - object_writer.write::<_, _, 8>(&prepared_rtp_bytes_sent); - } - if let ::core::option::Option::Some(prepared_rtx_bytes_received) = - prepared_rtx_bytes_received - { - object_writer.write::<_, _, 8>(&prepared_rtx_bytes_received); - } - if let ::core::option::Option::Some(prepared_rtx_bytes_sent) = - prepared_rtx_bytes_sent - { - object_writer.write::<_, _, 8>(&prepared_rtx_bytes_sent); - } - if let ::core::option::Option::Some(prepared_probation_bytes_sent) = - prepared_probation_bytes_sent - { - object_writer.write::<_, _, 8>(&prepared_probation_bytes_sent); - } - if let ::core::option::Option::Some(prepared_rtp_packet_loss_received) = - prepared_rtp_packet_loss_received - { - object_writer.write::<_, _, 8>(&prepared_rtp_packet_loss_received); - } - if let ::core::option::Option::Some(prepared_rtp_packet_loss_sent) = - prepared_rtp_packet_loss_sent - { - object_writer.write::<_, _, 8>(&prepared_rtp_packet_loss_sent); - } - object_writer.write::<_, _, 4>(&prepared_transport_id); - if let ::core::option::Option::Some(prepared_recv_bitrate) = - prepared_recv_bitrate - { - object_writer.write::<_, _, 4>(&prepared_recv_bitrate); - } - if let ::core::option::Option::Some(prepared_send_bitrate) = - prepared_send_bitrate - { - object_writer.write::<_, _, 4>(&prepared_send_bitrate); - } - if let ::core::option::Option::Some(prepared_rtp_recv_bitrate) = - prepared_rtp_recv_bitrate - { - object_writer.write::<_, _, 4>(&prepared_rtp_recv_bitrate); - } - if let ::core::option::Option::Some(prepared_rtp_send_bitrate) = - prepared_rtp_send_bitrate - { - object_writer.write::<_, _, 4>(&prepared_rtp_send_bitrate); - } - if let ::core::option::Option::Some(prepared_rtx_recv_bitrate) = - prepared_rtx_recv_bitrate - { - object_writer.write::<_, _, 4>(&prepared_rtx_recv_bitrate); - } - if let ::core::option::Option::Some(prepared_rtx_send_bitrate) = - prepared_rtx_send_bitrate - { - object_writer.write::<_, _, 4>(&prepared_rtx_send_bitrate); - } - if let ::core::option::Option::Some(prepared_probation_send_bitrate) = - prepared_probation_send_bitrate - { - object_writer.write::<_, _, 4>(&prepared_probation_send_bitrate); - } - if let ::core::option::Option::Some( - prepared_available_outgoing_bitrate, - ) = prepared_available_outgoing_bitrate - { - object_writer - .write::<_, _, 4>(&prepared_available_outgoing_bitrate); - } - if let ::core::option::Option::Some( - prepared_available_incoming_bitrate, - ) = prepared_available_incoming_bitrate - { - object_writer - .write::<_, _, 4>(&prepared_available_incoming_bitrate); - } - if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = - prepared_max_incoming_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_incoming_bitrate); - } - if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = - prepared_max_outgoing_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = - prepared_min_outgoing_bitrate - { - object_writer.write::<_, _, 4>(&prepared_min_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - object_writer.write::<_, _, 1>(&prepared_sctp_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Stats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Stats { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Stats { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Stats::create( - builder, - &self.transport_id, - self.timestamp, - self.sctp_state, - self.bytes_received, - self.recv_bitrate, - self.bytes_sent, - self.send_bitrate, - self.rtp_bytes_received, - self.rtp_recv_bitrate, - self.rtp_bytes_sent, - self.rtp_send_bitrate, - self.rtx_bytes_received, - self.rtx_recv_bitrate, - self.rtx_bytes_sent, - self.rtx_send_bitrate, - self.probation_bytes_sent, - self.probation_send_bitrate, - self.available_outgoing_bitrate, - self.available_incoming_bitrate, - self.max_incoming_bitrate, - self.max_outgoing_bitrate, - self.min_outgoing_bitrate, - self.rtp_packet_loss_received, - self.rtp_packet_loss_sent, - ) - } - } - - /// Builder for serializing an instance of the [Stats] type. - /// - /// Can be created using the [Stats::builder] method. - #[derive(Debug)] - #[must_use] - pub struct StatsBuilder(State); - - impl StatsBuilder<()> { - /// Setter for the [`transport_id` field](Stats#structfield.transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_id(self, value: T0) -> StatsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - StatsBuilder((value,)) - } - } - - impl StatsBuilder<(T0,)> { - /// Setter for the [`timestamp` field](Stats#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T1) -> StatsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - StatsBuilder((v0, value)) - } - - /// Sets the [`timestamp` field](Stats#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default(self) -> StatsBuilder<(T0, ::planus::DefaultValue)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1)> { - /// Setter for the [`sctp_state` field](Stats#structfield.sctp_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_state(self, value: T2) -> StatsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - StatsBuilder((v0, v1, value)) - } - - /// Sets the [`sctp_state` field](Stats#structfield.sctp_state) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_state_as_null(self) -> StatsBuilder<(T0, T1, ())> { - self.sctp_state(()) - } - } - - impl StatsBuilder<(T0, T1, T2)> { - /// Setter for the [`bytes_received` field](Stats#structfield.bytes_received). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_received(self, value: T3) -> StatsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - StatsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`bytes_received` field](Stats#structfield.bytes_received) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_received_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.bytes_received(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`recv_bitrate` field](Stats#structfield.recv_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn recv_bitrate(self, value: T4) -> StatsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - StatsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`recv_bitrate` field](Stats#structfield.recv_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn recv_bitrate_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.recv_bitrate(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`bytes_sent` field](Stats#structfield.bytes_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_sent(self, value: T5) -> StatsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`bytes_sent` field](Stats#structfield.bytes_sent) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bytes_sent_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> { - self.bytes_sent(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`send_bitrate` field](Stats#structfield.send_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn send_bitrate( - self, - value: T6, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`send_bitrate` field](Stats#structfield.send_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn send_bitrate_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.send_bitrate(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`rtp_bytes_received` field](Stats#structfield.rtp_bytes_received). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_bytes_received( - self, - value: T7, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`rtp_bytes_received` field](Stats#structfield.rtp_bytes_received) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_bytes_received_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.rtp_bytes_received(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`rtp_recv_bitrate` field](Stats#structfield.rtp_recv_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_recv_bitrate( - self, - value: T8, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`rtp_recv_bitrate` field](Stats#structfield.rtp_recv_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_recv_bitrate_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> - { - self.rtp_recv_bitrate(::planus::DefaultValue) - } - } - - impl StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`rtp_bytes_sent` field](Stats#structfield.rtp_bytes_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_bytes_sent( - self, - value: T9, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - - /// Sets the [`rtp_bytes_sent` field](Stats#structfield.rtp_bytes_sent) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_bytes_sent_as_default( - self, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, ::planus::DefaultValue)> - { - self.rtp_bytes_sent(::planus::DefaultValue) - } - } - - impl - StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - /// Setter for the [`rtp_send_bitrate` field](Stats#structfield.rtp_send_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_send_bitrate( - self, - value: T10, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`rtp_send_bitrate` field](Stats#structfield.rtp_send_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_send_bitrate_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - ::planus::DefaultValue, - )> { - self.rtp_send_bitrate(::planus::DefaultValue) - } - } - - impl - StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Setter for the [`rtx_bytes_received` field](Stats#structfield.rtx_bytes_received). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_bytes_received( - self, - value: T11, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - where - T11: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, value)) - } - - /// Sets the [`rtx_bytes_received` field](Stats#structfield.rtx_bytes_received) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_bytes_received_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - ::planus::DefaultValue, - )> { - self.rtx_bytes_received(::planus::DefaultValue) - } - } - - impl - StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`rtx_recv_bitrate` field](Stats#structfield.rtx_recv_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_recv_bitrate( - self, - value: T12, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - where - T12: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, value)) - } - - /// Sets the [`rtx_recv_bitrate` field](Stats#structfield.rtx_recv_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_recv_bitrate_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - ::planus::DefaultValue, - )> { - self.rtx_recv_bitrate(::planus::DefaultValue) - } - } - - impl - StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> - { - /// Setter for the [`rtx_bytes_sent` field](Stats#structfield.rtx_bytes_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_bytes_sent( - self, - value: T13, - ) -> StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - where - T13: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) = self.0; - StatsBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, value)) - } - - /// Sets the [`rtx_bytes_sent` field](Stats#structfield.rtx_bytes_sent) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_bytes_sent_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - ::planus::DefaultValue, - )> { - self.rtx_bytes_sent(::planus::DefaultValue) - } - } - - impl - StatsBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> - { - /// Setter for the [`rtx_send_bitrate` field](Stats#structfield.rtx_send_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_send_bitrate( - self, - value: T14, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - where - T14: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, value, - )) - } - - /// Sets the [`rtx_send_bitrate` field](Stats#structfield.rtx_send_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_send_bitrate_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - ::planus::DefaultValue, - )> { - self.rtx_send_bitrate(::planus::DefaultValue) - } - } - - impl - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - /// Setter for the [`probation_bytes_sent` field](Stats#structfield.probation_bytes_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn probation_bytes_sent( - self, - value: T15, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - where - T15: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, value, - )) - } - - /// Sets the [`probation_bytes_sent` field](Stats#structfield.probation_bytes_sent) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn probation_bytes_sent_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - ::planus::DefaultValue, - )> { - self.probation_bytes_sent(::planus::DefaultValue) - } - } - - impl - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - /// Setter for the [`probation_send_bitrate` field](Stats#structfield.probation_send_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn probation_send_bitrate( - self, - value: T16, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - )> - where - T16: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) = - self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, value, - )) - } - - /// Sets the [`probation_send_bitrate` field](Stats#structfield.probation_send_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn probation_send_bitrate_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - ::planus::DefaultValue, - )> { - self.probation_send_bitrate(::planus::DefaultValue) - } - } - - impl - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - )> - { - /// Setter for the [`available_outgoing_bitrate` field](Stats#structfield.available_outgoing_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn available_outgoing_bitrate( - self, - value: T17, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - where - T17: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) = - self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - value, - )) - } - - /// Sets the [`available_outgoing_bitrate` field](Stats#structfield.available_outgoing_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn available_outgoing_bitrate_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - (), - )> { - self.available_outgoing_bitrate(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - )> - { - /// Setter for the [`available_incoming_bitrate` field](Stats#structfield.available_incoming_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn available_incoming_bitrate( - self, - value: T18, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - )> - where - T18: ::planus::WriteAsOptional, - { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - ) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - v17, value, - )) - } - - /// Sets the [`available_incoming_bitrate` field](Stats#structfield.available_incoming_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn available_incoming_bitrate_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - (), - )> { - self.available_incoming_bitrate(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - )> - { - /// Setter for the [`max_incoming_bitrate` field](Stats#structfield.max_incoming_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_incoming_bitrate( - self, - value: T19, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - )> - where - T19: ::planus::WriteAsOptional, - { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - v18, - ) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - v17, v18, value, - )) - } - - /// Sets the [`max_incoming_bitrate` field](Stats#structfield.max_incoming_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_incoming_bitrate_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - (), - )> { - self.max_incoming_bitrate(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - )> - { - /// Setter for the [`max_outgoing_bitrate` field](Stats#structfield.max_outgoing_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_outgoing_bitrate( - self, - value: T20, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - )> - where - T20: ::planus::WriteAsOptional, - { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - v18, - v19, - ) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - v17, v18, v19, value, - )) - } - - /// Sets the [`max_outgoing_bitrate` field](Stats#structfield.max_outgoing_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_outgoing_bitrate_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - (), - )> { - self.max_outgoing_bitrate(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - )> - { - /// Setter for the [`min_outgoing_bitrate` field](Stats#structfield.min_outgoing_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_outgoing_bitrate( - self, - value: T21, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - )> - where - T21: ::planus::WriteAsOptional, - { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - v18, - v19, - v20, - ) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - v17, v18, v19, v20, value, - )) - } - - /// Sets the [`min_outgoing_bitrate` field](Stats#structfield.min_outgoing_bitrate) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_outgoing_bitrate_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - (), - )> { - self.min_outgoing_bitrate(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - )> - { - /// Setter for the [`rtp_packet_loss_received` field](Stats#structfield.rtp_packet_loss_received). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet_loss_received( - self, - value: T22, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - )> - where - T22: ::planus::WriteAsOptional, - { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - v18, - v19, - v20, - v21, - ) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - v17, v18, v19, v20, v21, value, - )) - } - - /// Sets the [`rtp_packet_loss_received` field](Stats#structfield.rtp_packet_loss_received) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet_loss_received_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - (), - )> { - self.rtp_packet_loss_received(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - )> - { - /// Setter for the [`rtp_packet_loss_sent` field](Stats#structfield.rtp_packet_loss_sent). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet_loss_sent( - self, - value: T23, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - )> - where - T23: ::planus::WriteAsOptional, - { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - v18, - v19, - v20, - v21, - v22, - ) = self.0; - StatsBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, - v17, v18, v19, v20, v21, v22, value, - )) - } - - /// Sets the [`rtp_packet_loss_sent` field](Stats#structfield.rtp_packet_loss_sent) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet_loss_sent_as_null( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - (), - )> { - self.rtp_packet_loss_sent(()) - } - } - - impl< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - > - StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - )> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Stats]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - T16: ::planus::WriteAsDefault, - T17: ::planus::WriteAsOptional, - T18: ::planus::WriteAsOptional, - T19: ::planus::WriteAsOptional, - T20: ::planus::WriteAsOptional, - T21: ::planus::WriteAsOptional, - T22: ::planus::WriteAsOptional, - T23: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - T16: ::planus::WriteAsDefault, - T17: ::planus::WriteAsOptional, - T18: ::planus::WriteAsOptional, - T19: ::planus::WriteAsOptional, - T20: ::planus::WriteAsOptional, - T21: ::planus::WriteAsOptional, - T22: ::planus::WriteAsOptional, - T23: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - T16: ::planus::WriteAsDefault, - T17: ::planus::WriteAsOptional, - T18: ::planus::WriteAsOptional, - T19: ::planus::WriteAsOptional, - T20: ::planus::WriteAsOptional, - T21: ::planus::WriteAsOptional, - T22: ::planus::WriteAsOptional, - T23: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - )> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let ( - v0, - v1, - v2, - v3, - v4, - v5, - v6, - v7, - v8, - v9, - v10, - v11, - v12, - v13, - v14, - v15, - v16, - v17, - v18, - v19, - v20, - v21, - v22, - v23, - ) = &self.0; - Stats::create( - builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, - v15, v16, v17, v18, v19, v20, v21, v22, v23, - ) - } - } - - /// Reference to a deserialized [Stats]. - #[derive(Copy, Clone)] - pub struct StatsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> StatsRef<'a> { - /// Getter for the [`transport_id` field](Stats#structfield.transport_id). - #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Stats", "transport_id") - } - - /// Getter for the [`timestamp` field](Stats#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Stats", "timestamp")?.unwrap_or(0)) - } - - /// Getter for the [`sctp_state` field](Stats#structfield.sctp_state). - #[inline] - pub fn sctp_state( - &self, - ) -> ::planus::Result<::core::option::Option> - { - self.0.access(2, "Stats", "sctp_state") - } - - /// Getter for the [`bytes_received` field](Stats#structfield.bytes_received). - #[inline] - pub fn bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "Stats", "bytes_received")?.unwrap_or(0), - ) - } - - /// Getter for the [`recv_bitrate` field](Stats#structfield.recv_bitrate). - #[inline] - pub fn recv_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(4, "Stats", "recv_bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`bytes_sent` field](Stats#structfield.bytes_sent). - #[inline] - pub fn bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(5, "Stats", "bytes_sent")?.unwrap_or(0), - ) - } - - /// Getter for the [`send_bitrate` field](Stats#structfield.send_bitrate). - #[inline] - pub fn send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(6, "Stats", "send_bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`rtp_bytes_received` field](Stats#structfield.rtp_bytes_received). - #[inline] - pub fn rtp_bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "Stats", "rtp_bytes_received")? - .unwrap_or(0), - ) - } - - /// Getter for the [`rtp_recv_bitrate` field](Stats#structfield.rtp_recv_bitrate). - #[inline] - pub fn rtp_recv_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(8, "Stats", "rtp_recv_bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`rtp_bytes_sent` field](Stats#structfield.rtp_bytes_sent). - #[inline] - pub fn rtp_bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(9, "Stats", "rtp_bytes_sent")?.unwrap_or(0), - ) - } - - /// Getter for the [`rtp_send_bitrate` field](Stats#structfield.rtp_send_bitrate). - #[inline] - pub fn rtp_send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(10, "Stats", "rtp_send_bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`rtx_bytes_received` field](Stats#structfield.rtx_bytes_received). - #[inline] - pub fn rtx_bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(11, "Stats", "rtx_bytes_received")? - .unwrap_or(0), - ) - } - - /// Getter for the [`rtx_recv_bitrate` field](Stats#structfield.rtx_recv_bitrate). - #[inline] - pub fn rtx_recv_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(12, "Stats", "rtx_recv_bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`rtx_bytes_sent` field](Stats#structfield.rtx_bytes_sent). - #[inline] - pub fn rtx_bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(13, "Stats", "rtx_bytes_sent")?.unwrap_or(0), - ) - } - - /// Getter for the [`rtx_send_bitrate` field](Stats#structfield.rtx_send_bitrate). - #[inline] - pub fn rtx_send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(14, "Stats", "rtx_send_bitrate")?.unwrap_or(0), - ) - } - - /// Getter for the [`probation_bytes_sent` field](Stats#structfield.probation_bytes_sent). - #[inline] - pub fn probation_bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(15, "Stats", "probation_bytes_sent")? - .unwrap_or(0), - ) - } - - /// Getter for the [`probation_send_bitrate` field](Stats#structfield.probation_send_bitrate). - #[inline] - pub fn probation_send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(16, "Stats", "probation_send_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`available_outgoing_bitrate` field](Stats#structfield.available_outgoing_bitrate). - #[inline] - pub fn available_outgoing_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(17, "Stats", "available_outgoing_bitrate") - } - - /// Getter for the [`available_incoming_bitrate` field](Stats#structfield.available_incoming_bitrate). - #[inline] - pub fn available_incoming_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(18, "Stats", "available_incoming_bitrate") - } - - /// Getter for the [`max_incoming_bitrate` field](Stats#structfield.max_incoming_bitrate). - #[inline] - pub fn max_incoming_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(19, "Stats", "max_incoming_bitrate") - } - - /// Getter for the [`max_outgoing_bitrate` field](Stats#structfield.max_outgoing_bitrate). - #[inline] - pub fn max_outgoing_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(20, "Stats", "max_outgoing_bitrate") - } - - /// Getter for the [`min_outgoing_bitrate` field](Stats#structfield.min_outgoing_bitrate). - #[inline] - pub fn min_outgoing_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(21, "Stats", "min_outgoing_bitrate") - } - - /// Getter for the [`rtp_packet_loss_received` field](Stats#structfield.rtp_packet_loss_received). - #[inline] - pub fn rtp_packet_loss_received( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(22, "Stats", "rtp_packet_loss_received") - } - - /// Getter for the [`rtp_packet_loss_sent` field](Stats#structfield.rtp_packet_loss_sent). - #[inline] - pub fn rtp_packet_loss_sent( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(23, "Stats", "rtp_packet_loss_sent") - } - } - - impl<'a> ::core::fmt::Debug for StatsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("StatsRef"); - f.field("transport_id", &self.transport_id()); - f.field("timestamp", &self.timestamp()); - if let ::core::option::Option::Some(field_sctp_state) = - self.sctp_state().transpose() - { - f.field("sctp_state", &field_sctp_state); - } - f.field("bytes_received", &self.bytes_received()); - f.field("recv_bitrate", &self.recv_bitrate()); - f.field("bytes_sent", &self.bytes_sent()); - f.field("send_bitrate", &self.send_bitrate()); - f.field("rtp_bytes_received", &self.rtp_bytes_received()); - f.field("rtp_recv_bitrate", &self.rtp_recv_bitrate()); - f.field("rtp_bytes_sent", &self.rtp_bytes_sent()); - f.field("rtp_send_bitrate", &self.rtp_send_bitrate()); - f.field("rtx_bytes_received", &self.rtx_bytes_received()); - f.field("rtx_recv_bitrate", &self.rtx_recv_bitrate()); - f.field("rtx_bytes_sent", &self.rtx_bytes_sent()); - f.field("rtx_send_bitrate", &self.rtx_send_bitrate()); - f.field("probation_bytes_sent", &self.probation_bytes_sent()); - f.field("probation_send_bitrate", &self.probation_send_bitrate()); - if let ::core::option::Option::Some(field_available_outgoing_bitrate) = - self.available_outgoing_bitrate().transpose() - { - f.field( - "available_outgoing_bitrate", - &field_available_outgoing_bitrate, - ); - } - if let ::core::option::Option::Some(field_available_incoming_bitrate) = - self.available_incoming_bitrate().transpose() - { - f.field( - "available_incoming_bitrate", - &field_available_incoming_bitrate, - ); - } - if let ::core::option::Option::Some(field_max_incoming_bitrate) = - self.max_incoming_bitrate().transpose() - { - f.field("max_incoming_bitrate", &field_max_incoming_bitrate); - } - if let ::core::option::Option::Some(field_max_outgoing_bitrate) = - self.max_outgoing_bitrate().transpose() - { - f.field("max_outgoing_bitrate", &field_max_outgoing_bitrate); - } - if let ::core::option::Option::Some(field_min_outgoing_bitrate) = - self.min_outgoing_bitrate().transpose() - { - f.field("min_outgoing_bitrate", &field_min_outgoing_bitrate); - } - if let ::core::option::Option::Some(field_rtp_packet_loss_received) = - self.rtp_packet_loss_received().transpose() - { - f.field("rtp_packet_loss_received", &field_rtp_packet_loss_received); - } - if let ::core::option::Option::Some(field_rtp_packet_loss_sent) = - self.rtp_packet_loss_sent().transpose() - { - f.field("rtp_packet_loss_sent", &field_rtp_packet_loss_sent); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Stats { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: StatsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - sctp_state: if let ::core::option::Option::Some(sctp_state) = - value.sctp_state()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - sctp_state, - )?) - } else { - ::core::option::Option::None - }, - bytes_received: ::core::convert::TryInto::try_into( - value.bytes_received()?, - )?, - recv_bitrate: ::core::convert::TryInto::try_into(value.recv_bitrate()?)?, - bytes_sent: ::core::convert::TryInto::try_into(value.bytes_sent()?)?, - send_bitrate: ::core::convert::TryInto::try_into(value.send_bitrate()?)?, - rtp_bytes_received: ::core::convert::TryInto::try_into( - value.rtp_bytes_received()?, - )?, - rtp_recv_bitrate: ::core::convert::TryInto::try_into( - value.rtp_recv_bitrate()?, - )?, - rtp_bytes_sent: ::core::convert::TryInto::try_into( - value.rtp_bytes_sent()?, - )?, - rtp_send_bitrate: ::core::convert::TryInto::try_into( - value.rtp_send_bitrate()?, - )?, - rtx_bytes_received: ::core::convert::TryInto::try_into( - value.rtx_bytes_received()?, - )?, - rtx_recv_bitrate: ::core::convert::TryInto::try_into( - value.rtx_recv_bitrate()?, - )?, - rtx_bytes_sent: ::core::convert::TryInto::try_into( - value.rtx_bytes_sent()?, - )?, - rtx_send_bitrate: ::core::convert::TryInto::try_into( - value.rtx_send_bitrate()?, - )?, - probation_bytes_sent: ::core::convert::TryInto::try_into( - value.probation_bytes_sent()?, - )?, - probation_send_bitrate: ::core::convert::TryInto::try_into( - value.probation_send_bitrate()?, - )?, - available_outgoing_bitrate: if let ::core::option::Option::Some( - available_outgoing_bitrate, - ) = value.available_outgoing_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - available_outgoing_bitrate, - )?) - } else { - ::core::option::Option::None - }, - available_incoming_bitrate: if let ::core::option::Option::Some( - available_incoming_bitrate, - ) = value.available_incoming_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - available_incoming_bitrate, - )?) - } else { - ::core::option::Option::None - }, - max_incoming_bitrate: if let ::core::option::Option::Some( - max_incoming_bitrate, - ) = value.max_incoming_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - max_incoming_bitrate, - )?) - } else { - ::core::option::Option::None - }, - max_outgoing_bitrate: if let ::core::option::Option::Some( - max_outgoing_bitrate, - ) = value.max_outgoing_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - max_outgoing_bitrate, - )?) - } else { - ::core::option::Option::None - }, - min_outgoing_bitrate: if let ::core::option::Option::Some( - min_outgoing_bitrate, - ) = value.min_outgoing_bitrate()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - min_outgoing_bitrate, - )?) - } else { - ::core::option::Option::None - }, - rtp_packet_loss_received: if let ::core::option::Option::Some( - rtp_packet_loss_received, - ) = value.rtp_packet_loss_received()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - rtp_packet_loss_received, - )?) - } else { - ::core::option::Option::None - }, - rtp_packet_loss_sent: if let ::core::option::Option::Some( - rtp_packet_loss_sent, - ) = value.rtp_packet_loss_sent()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - rtp_packet_loss_sent, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for StatsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for StatsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[StatsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Stats { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for StatsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[StatsRef]", "read_as_root", 0) - }) - } - } - - /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetMaxIncomingBitrateRequest { - /// The field `max_incoming_bitrate` in the table `SetMaxIncomingBitrateRequest` - pub max_incoming_bitrate: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetMaxIncomingBitrateRequest { - fn default() -> Self { - Self { - max_incoming_bitrate: 0, - } - } - } - - impl SetMaxIncomingBitrateRequest { - /// Creates a [SetMaxIncomingBitrateRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetMaxIncomingBitrateRequestBuilder<()> { - SetMaxIncomingBitrateRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_max_incoming_bitrate: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_max_incoming_bitrate = - field_max_incoming_bitrate.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_max_incoming_bitrate.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = - prepared_max_incoming_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_incoming_bitrate); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for SetMaxIncomingBitrateRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetMaxIncomingBitrateRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetMaxIncomingBitrateRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetMaxIncomingBitrateRequest::create(builder, self.max_incoming_bitrate) - } - } - - /// Builder for serializing an instance of the [SetMaxIncomingBitrateRequest] type. - /// - /// Can be created using the [SetMaxIncomingBitrateRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetMaxIncomingBitrateRequestBuilder(State); - - impl SetMaxIncomingBitrateRequestBuilder<()> { - /// Setter for the [`max_incoming_bitrate` field](SetMaxIncomingBitrateRequest#structfield.max_incoming_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_incoming_bitrate( - self, - value: T0, - ) -> SetMaxIncomingBitrateRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SetMaxIncomingBitrateRequestBuilder((value,)) - } - - /// Sets the [`max_incoming_bitrate` field](SetMaxIncomingBitrateRequest#structfield.max_incoming_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_incoming_bitrate_as_default( - self, - ) -> SetMaxIncomingBitrateRequestBuilder<(::planus::DefaultValue,)> - { - self.max_incoming_bitrate(::planus::DefaultValue) - } - } - - impl SetMaxIncomingBitrateRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetMaxIncomingBitrateRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for SetMaxIncomingBitrateRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for SetMaxIncomingBitrateRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for SetMaxIncomingBitrateRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetMaxIncomingBitrateRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetMaxIncomingBitrateRequest]. - #[derive(Copy, Clone)] - pub struct SetMaxIncomingBitrateRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetMaxIncomingBitrateRequestRef<'a> { - /// Getter for the [`max_incoming_bitrate` field](SetMaxIncomingBitrateRequest#structfield.max_incoming_bitrate). - #[inline] - pub fn max_incoming_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SetMaxIncomingBitrateRequest", "max_incoming_bitrate")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SetMaxIncomingBitrateRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetMaxIncomingBitrateRequestRef"); - f.field("max_incoming_bitrate", &self.max_incoming_bitrate()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for SetMaxIncomingBitrateRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetMaxIncomingBitrateRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - max_incoming_bitrate: ::core::convert::TryInto::try_into( - value.max_incoming_bitrate()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetMaxIncomingBitrateRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetMaxIncomingBitrateRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetMaxIncomingBitrateRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SetMaxIncomingBitrateRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetMaxIncomingBitrateRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetMaxIncomingBitrateRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:176` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetMaxOutgoingBitrateRequest { - /// The field `max_outgoing_bitrate` in the table `SetMaxOutgoingBitrateRequest` - pub max_outgoing_bitrate: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetMaxOutgoingBitrateRequest { - fn default() -> Self { - Self { - max_outgoing_bitrate: 0, - } - } - } - - impl SetMaxOutgoingBitrateRequest { - /// Creates a [SetMaxOutgoingBitrateRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetMaxOutgoingBitrateRequestBuilder<()> { - SetMaxOutgoingBitrateRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_max_outgoing_bitrate: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_max_outgoing_bitrate = - field_max_outgoing_bitrate.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_max_outgoing_bitrate.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = - prepared_max_outgoing_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_outgoing_bitrate); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for SetMaxOutgoingBitrateRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetMaxOutgoingBitrateRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetMaxOutgoingBitrateRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetMaxOutgoingBitrateRequest::create(builder, self.max_outgoing_bitrate) - } - } - - /// Builder for serializing an instance of the [SetMaxOutgoingBitrateRequest] type. - /// - /// Can be created using the [SetMaxOutgoingBitrateRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetMaxOutgoingBitrateRequestBuilder(State); - - impl SetMaxOutgoingBitrateRequestBuilder<()> { - /// Setter for the [`max_outgoing_bitrate` field](SetMaxOutgoingBitrateRequest#structfield.max_outgoing_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_outgoing_bitrate( - self, - value: T0, - ) -> SetMaxOutgoingBitrateRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SetMaxOutgoingBitrateRequestBuilder((value,)) - } - - /// Sets the [`max_outgoing_bitrate` field](SetMaxOutgoingBitrateRequest#structfield.max_outgoing_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_outgoing_bitrate_as_default( - self, - ) -> SetMaxOutgoingBitrateRequestBuilder<(::planus::DefaultValue,)> - { - self.max_outgoing_bitrate(::planus::DefaultValue) - } - } - - impl SetMaxOutgoingBitrateRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetMaxOutgoingBitrateRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for SetMaxOutgoingBitrateRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for SetMaxOutgoingBitrateRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for SetMaxOutgoingBitrateRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetMaxOutgoingBitrateRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetMaxOutgoingBitrateRequest]. - #[derive(Copy, Clone)] - pub struct SetMaxOutgoingBitrateRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetMaxOutgoingBitrateRequestRef<'a> { - /// Getter for the [`max_outgoing_bitrate` field](SetMaxOutgoingBitrateRequest#structfield.max_outgoing_bitrate). - #[inline] - pub fn max_outgoing_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SetMaxOutgoingBitrateRequest", "max_outgoing_bitrate")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SetMaxOutgoingBitrateRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetMaxOutgoingBitrateRequestRef"); - f.field("max_outgoing_bitrate", &self.max_outgoing_bitrate()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for SetMaxOutgoingBitrateRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetMaxOutgoingBitrateRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - max_outgoing_bitrate: ::core::convert::TryInto::try_into( - value.max_outgoing_bitrate()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetMaxOutgoingBitrateRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetMaxOutgoingBitrateRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetMaxOutgoingBitrateRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SetMaxOutgoingBitrateRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetMaxOutgoingBitrateRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetMaxOutgoingBitrateRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:180` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SetMinOutgoingBitrateRequest { - /// The field `min_outgoing_bitrate` in the table `SetMinOutgoingBitrateRequest` - pub min_outgoing_bitrate: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetMinOutgoingBitrateRequest { - fn default() -> Self { - Self { - min_outgoing_bitrate: 0, - } - } - } - - impl SetMinOutgoingBitrateRequest { - /// Creates a [SetMinOutgoingBitrateRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetMinOutgoingBitrateRequestBuilder<()> { - SetMinOutgoingBitrateRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_min_outgoing_bitrate: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_min_outgoing_bitrate = - field_min_outgoing_bitrate.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_min_outgoing_bitrate.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = - prepared_min_outgoing_bitrate - { - object_writer.write::<_, _, 4>(&prepared_min_outgoing_bitrate); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for SetMinOutgoingBitrateRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SetMinOutgoingBitrateRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SetMinOutgoingBitrateRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetMinOutgoingBitrateRequest::create(builder, self.min_outgoing_bitrate) - } - } - - /// Builder for serializing an instance of the [SetMinOutgoingBitrateRequest] type. - /// - /// Can be created using the [SetMinOutgoingBitrateRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SetMinOutgoingBitrateRequestBuilder(State); - - impl SetMinOutgoingBitrateRequestBuilder<()> { - /// Setter for the [`min_outgoing_bitrate` field](SetMinOutgoingBitrateRequest#structfield.min_outgoing_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_outgoing_bitrate( - self, - value: T0, - ) -> SetMinOutgoingBitrateRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SetMinOutgoingBitrateRequestBuilder((value,)) - } - - /// Sets the [`min_outgoing_bitrate` field](SetMinOutgoingBitrateRequest#structfield.min_outgoing_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_outgoing_bitrate_as_default( - self, - ) -> SetMinOutgoingBitrateRequestBuilder<(::planus::DefaultValue,)> - { - self.min_outgoing_bitrate(::planus::DefaultValue) - } - } - - impl SetMinOutgoingBitrateRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetMinOutgoingBitrateRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for SetMinOutgoingBitrateRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for SetMinOutgoingBitrateRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for SetMinOutgoingBitrateRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SetMinOutgoingBitrateRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [SetMinOutgoingBitrateRequest]. - #[derive(Copy, Clone)] - pub struct SetMinOutgoingBitrateRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SetMinOutgoingBitrateRequestRef<'a> { - /// Getter for the [`min_outgoing_bitrate` field](SetMinOutgoingBitrateRequest#structfield.min_outgoing_bitrate). - #[inline] - pub fn min_outgoing_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SetMinOutgoingBitrateRequest", "min_outgoing_bitrate")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SetMinOutgoingBitrateRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SetMinOutgoingBitrateRequestRef"); - f.field("min_outgoing_bitrate", &self.min_outgoing_bitrate()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for SetMinOutgoingBitrateRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SetMinOutgoingBitrateRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - min_outgoing_bitrate: ::core::convert::TryInto::try_into( - value.min_outgoing_bitrate()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SetMinOutgoingBitrateRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SetMinOutgoingBitrateRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SetMinOutgoingBitrateRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SetMinOutgoingBitrateRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SetMinOutgoingBitrateRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SetMinOutgoingBitrateRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:184` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct EnableTraceEventRequest { - /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec, - } - - impl EnableTraceEventRequest { - /// Creates a [EnableTraceEventRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> EnableTraceEventRequestBuilder<()> { - EnableTraceEventRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - ) -> ::planus::Offset { - let prepared_events = field_events.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_events); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for EnableTraceEventRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - EnableTraceEventRequest::create(builder, &self.events) - } - } - - /// Builder for serializing an instance of the [EnableTraceEventRequest] type. - /// - /// Can be created using the [EnableTraceEventRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct EnableTraceEventRequestBuilder(State); - - impl EnableTraceEventRequestBuilder<()> { - /// Setter for the [`events` field](EnableTraceEventRequest#structfield.events). - #[inline] - #[allow(clippy::type_complexity)] - pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - { - EnableTraceEventRequestBuilder((value,)) - } - } - - impl EnableTraceEventRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [EnableTraceEventRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for EnableTraceEventRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - EnableTraceEventRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [EnableTraceEventRequest]. - #[derive(Copy, Clone)] - pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> EnableTraceEventRequestRef<'a> { - /// Getter for the [`events` field](EnableTraceEventRequest#structfield.events). - #[inline] - pub fn events( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::core::result::Result< - self::TraceEventType, - ::planus::errors::UnknownEnumTag, - >, - >, - > { - self.0 - .access_required(0, "EnableTraceEventRequest", "events") - } - } - - impl<'a> ::core::fmt::Debug for EnableTraceEventRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("EnableTraceEventRequestRef"); - f.field("events", &self.events()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for EnableTraceEventRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: EnableTraceEventRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - events: value.events()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for EnableTraceEventRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for EnableTraceEventRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for EnableTraceEventRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseProducerRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:188` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseProducerRequest { - /// The field `producer_id` in the table `CloseProducerRequest` - pub producer_id: ::planus::alloc::string::String, - } - - impl CloseProducerRequest { - /// Creates a [CloseProducerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseProducerRequestBuilder<()> { - CloseProducerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_producer_id = field_producer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for CloseProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseProducerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseProducerRequest::create(builder, &self.producer_id) - } - } - - /// Builder for serializing an instance of the [CloseProducerRequest] type. - /// - /// Can be created using the [CloseProducerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseProducerRequestBuilder(State); - - impl CloseProducerRequestBuilder<()> { - /// Setter for the [`producer_id` field](CloseProducerRequest#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T0) -> CloseProducerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseProducerRequestBuilder((value,)) - } - } - - impl CloseProducerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseProducerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseProducerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseProducerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseProducerRequest]. - #[derive(Copy, Clone)] - pub struct CloseProducerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseProducerRequestRef<'a> { - /// Getter for the [`producer_id` field](CloseProducerRequest#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseProducerRequest", "producer_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseProducerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseProducerRequestRef"); - f.field("producer_id", &self.producer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseProducerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseProducerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseProducerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseProducerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseProducerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CloseProducerRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseProducerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseProducerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:192` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseConsumerRequest { - /// The field `consumer_id` in the table `CloseConsumerRequest` - pub consumer_id: ::planus::alloc::string::String, - } - - impl CloseConsumerRequest { - /// Creates a [CloseConsumerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseConsumerRequestBuilder<()> { - CloseConsumerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_consumer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_consumer_id = field_consumer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_consumer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseConsumerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for CloseConsumerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseConsumerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseConsumerRequest::create(builder, &self.consumer_id) - } - } - - /// Builder for serializing an instance of the [CloseConsumerRequest] type. - /// - /// Can be created using the [CloseConsumerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseConsumerRequestBuilder(State); - - impl CloseConsumerRequestBuilder<()> { - /// Setter for the [`consumer_id` field](CloseConsumerRequest#structfield.consumer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn consumer_id(self, value: T0) -> CloseConsumerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseConsumerRequestBuilder((value,)) - } - } - - impl CloseConsumerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseConsumerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseConsumerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseConsumerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseConsumerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseConsumerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseConsumerRequest]. - #[derive(Copy, Clone)] - pub struct CloseConsumerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseConsumerRequestRef<'a> { - /// Getter for the [`consumer_id` field](CloseConsumerRequest#structfield.consumer_id). - #[inline] - pub fn consumer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseConsumerRequest", "consumer_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseConsumerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseConsumerRequestRef"); - f.field("consumer_id", &self.consumer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseConsumerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseConsumerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - consumer_id: ::core::convert::TryInto::try_into(value.consumer_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseConsumerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseConsumerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseConsumerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CloseConsumerRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseConsumerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseConsumerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:196` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseDataProducerRequest { - /// The field `data_producer_id` in the table `CloseDataProducerRequest` - pub data_producer_id: ::planus::alloc::string::String, - } - - impl CloseDataProducerRequest { - /// Creates a [CloseDataProducerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseDataProducerRequestBuilder<()> { - CloseDataProducerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data_producer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_data_producer_id = field_data_producer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data_producer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseDataProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CloseDataProducerRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseDataProducerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseDataProducerRequest::create(builder, &self.data_producer_id) - } - } - - /// Builder for serializing an instance of the [CloseDataProducerRequest] type. - /// - /// Can be created using the [CloseDataProducerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseDataProducerRequestBuilder(State); - - impl CloseDataProducerRequestBuilder<()> { - /// Setter for the [`data_producer_id` field](CloseDataProducerRequest#structfield.data_producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_producer_id( - self, - value: T0, - ) -> CloseDataProducerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseDataProducerRequestBuilder((value,)) - } - } - - impl CloseDataProducerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseDataProducerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseDataProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseDataProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseDataProducerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseDataProducerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseDataProducerRequest]. - #[derive(Copy, Clone)] - pub struct CloseDataProducerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseDataProducerRequestRef<'a> { - /// Getter for the [`data_producer_id` field](CloseDataProducerRequest#structfield.data_producer_id). - #[inline] - pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseDataProducerRequest", "data_producer_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseDataProducerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseDataProducerRequestRef"); - f.field("data_producer_id", &self.data_producer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseDataProducerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseDataProducerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data_producer_id: ::core::convert::TryInto::try_into( - value.data_producer_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseDataProducerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseDataProducerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseDataProducerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CloseDataProducerRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseDataProducerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseDataProducerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:200` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseDataConsumerRequest { - /// The field `data_consumer_id` in the table `CloseDataConsumerRequest` - pub data_consumer_id: ::planus::alloc::string::String, - } - - impl CloseDataConsumerRequest { - /// Creates a [CloseDataConsumerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseDataConsumerRequestBuilder<()> { - CloseDataConsumerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data_consumer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_data_consumer_id = field_data_consumer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data_consumer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseDataConsumerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CloseDataConsumerRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseDataConsumerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseDataConsumerRequest::create(builder, &self.data_consumer_id) - } - } - - /// Builder for serializing an instance of the [CloseDataConsumerRequest] type. - /// - /// Can be created using the [CloseDataConsumerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseDataConsumerRequestBuilder(State); - - impl CloseDataConsumerRequestBuilder<()> { - /// Setter for the [`data_consumer_id` field](CloseDataConsumerRequest#structfield.data_consumer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_consumer_id( - self, - value: T0, - ) -> CloseDataConsumerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseDataConsumerRequestBuilder((value,)) - } - } - - impl CloseDataConsumerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseDataConsumerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseDataConsumerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseDataConsumerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseDataConsumerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseDataConsumerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseDataConsumerRequest]. - #[derive(Copy, Clone)] - pub struct CloseDataConsumerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseDataConsumerRequestRef<'a> { - /// Getter for the [`data_consumer_id` field](CloseDataConsumerRequest#structfield.data_consumer_id). - #[inline] - pub fn data_consumer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseDataConsumerRequest", "data_consumer_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseDataConsumerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseDataConsumerRequestRef"); - f.field("data_consumer_id", &self.data_consumer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseDataConsumerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseDataConsumerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data_consumer_id: ::core::convert::TryInto::try_into( - value.data_consumer_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseDataConsumerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseDataConsumerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseDataConsumerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CloseDataConsumerRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseDataConsumerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseDataConsumerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SendRtcpNotification` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:206` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SendRtcpNotification { - /// The field `data` in the table `SendRtcpNotification` - pub data: ::planus::alloc::vec::Vec, - } - - impl SendRtcpNotification { - /// Creates a [SendRtcpNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SendRtcpNotificationBuilder<()> { - SendRtcpNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u8]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SendRtcpNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SendRtcpNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SendRtcpNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendRtcpNotification::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [SendRtcpNotification] type. - /// - /// Can be created using the [SendRtcpNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SendRtcpNotificationBuilder(State); - - impl SendRtcpNotificationBuilder<()> { - /// Setter for the [`data` field](SendRtcpNotification#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> SendRtcpNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - SendRtcpNotificationBuilder((value,)) - } - } - - impl SendRtcpNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendRtcpNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for SendRtcpNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SendRtcpNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for SendRtcpNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SendRtcpNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [SendRtcpNotification]. - #[derive(Copy, Clone)] - pub struct SendRtcpNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SendRtcpNotificationRef<'a> { - /// Getter for the [`data` field](SendRtcpNotification#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "SendRtcpNotification", "data") - } - } - - impl<'a> ::core::fmt::Debug for SendRtcpNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SendRtcpNotificationRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SendRtcpNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SendRtcpNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: value.data()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SendRtcpNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SendRtcpNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SendRtcpNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SendRtcpNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SendRtcpNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SendRtcpNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:212` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SctpStateChangeNotification { - /// The field `sctp_state` in the table `SctpStateChangeNotification` - pub sctp_state: super::sctp_association::SctpState, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SctpStateChangeNotification { - fn default() -> Self { - Self { - sctp_state: super::sctp_association::SctpState::New, - } - } - } - - impl SctpStateChangeNotification { - /// Creates a [SctpStateChangeNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SctpStateChangeNotificationBuilder<()> { - SctpStateChangeNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_sctp_state: impl ::planus::WriteAsDefault< - super::sctp_association::SctpState, - super::sctp_association::SctpState, - >, - ) -> ::planus::Offset { - let prepared_sctp_state = - field_sctp_state.prepare(builder, &super::sctp_association::SctpState::New); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_sctp_state.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - object_writer.write::<_, _, 1>(&prepared_sctp_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for SctpStateChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for SctpStateChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SctpStateChangeNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SctpStateChangeNotification::create(builder, self.sctp_state) - } - } - - /// Builder for serializing an instance of the [SctpStateChangeNotification] type. - /// - /// Can be created using the [SctpStateChangeNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SctpStateChangeNotificationBuilder(State); - - impl SctpStateChangeNotificationBuilder<()> { - /// Setter for the [`sctp_state` field](SctpStateChangeNotification#structfield.sctp_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_state(self, value: T0) -> SctpStateChangeNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault< - super::sctp_association::SctpState, - super::sctp_association::SctpState, - >, - { - SctpStateChangeNotificationBuilder((value,)) - } - - /// Sets the [`sctp_state` field](SctpStateChangeNotification#structfield.sctp_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn sctp_state_as_default( - self, - ) -> SctpStateChangeNotificationBuilder<(::planus::DefaultValue,)> { - self.sctp_state(::planus::DefaultValue) - } - } - - impl SctpStateChangeNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SctpStateChangeNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - super::sctp_association::SctpState, - super::sctp_association::SctpState, - >, - > ::planus::WriteAs<::planus::Offset> - for SctpStateChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - super::sctp_association::SctpState, - super::sctp_association::SctpState, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for SctpStateChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault< - super::sctp_association::SctpState, - super::sctp_association::SctpState, - >, - > ::planus::WriteAsOffset - for SctpStateChangeNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SctpStateChangeNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [SctpStateChangeNotification]. - #[derive(Copy, Clone)] - pub struct SctpStateChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SctpStateChangeNotificationRef<'a> { - /// Getter for the [`sctp_state` field](SctpStateChangeNotification#structfield.sctp_state). - #[inline] - pub fn sctp_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SctpStateChangeNotification", "sctp_state")? - .unwrap_or(super::sctp_association::SctpState::New), - ) - } - } - - impl<'a> ::core::fmt::Debug for SctpStateChangeNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SctpStateChangeNotificationRef"); - f.field("sctp_state", &self.sctp_state()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for SctpStateChangeNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SctpStateChangeNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - sctp_state: ::core::convert::TryInto::try_into(value.sctp_state()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SctpStateChangeNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SctpStateChangeNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SctpStateChangeNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for SctpStateChangeNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SctpStateChangeNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[SctpStateChangeNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The union `TraceInfo` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:216` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub enum TraceInfo { - /// The variant of type `BweTraceInfo` in the union `TraceInfo` - BweTraceInfo(::planus::alloc::boxed::Box), - } - - impl TraceInfo { - /// Creates a [TraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceInfoBuilder<::planus::Uninitialized> { - TraceInfoBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_bwe_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for TraceInfo { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::BweTraceInfo(value) => Self::create_bwe_trace_info(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [TraceInfo] type. - /// - /// Can be created using the [TraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TraceInfoBuilder(T); - - impl TraceInfoBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`BweTraceInfo` variant](TraceInfo#variant.BweTraceInfo). - #[inline] - pub fn bwe_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - } - - impl TraceInfoBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [TraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [TraceInfo]. - #[derive(Copy, Clone, Debug)] - pub enum TraceInfoRef<'a> { - BweTraceInfo(self::BweTraceInfoRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for TraceInfo { - type Error = ::planus::Error; - - fn try_from(value: TraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - TraceInfoRef::BweTraceInfo(value) => { - Self::BweTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for TraceInfoRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::BweTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The enum `BweType` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:220` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum BweType { - /// The variant `TRANSPORT_CC` in the enum `BweType` - TransportCc = 0, - - /// The variant `REMB` in the enum `BweType` - Remb = 1, - } - - impl BweType { - /// Array containing all valid variants of BweType - pub const ENUM_VALUES: [Self; 2] = [Self::TransportCc, Self::Remb]; - } - - impl ::core::convert::TryFrom for BweType { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(BweType::TransportCc), - 1 => ::core::result::Result::Ok(BweType::Remb), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: BweType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for BweType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for BweType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for BweType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> BweType { - *self - } - } - - impl ::planus::WriteAsDefault for BweType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &BweType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for BweType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for BweType { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for BweType { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "BweType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for BweType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `BweTraceInfo` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:225` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct BweTraceInfo { - /// The field `bwe_type` in the table `BweTraceInfo` - pub bwe_type: self::BweType, - /// The field `desired_bitrate` in the table `BweTraceInfo` - pub desired_bitrate: u32, - /// The field `effective_desired_bitrate` in the table `BweTraceInfo` - pub effective_desired_bitrate: u32, - /// The field `min_bitrate` in the table `BweTraceInfo` - pub min_bitrate: u32, - /// The field `max_bitrate` in the table `BweTraceInfo` - pub max_bitrate: u32, - /// The field `start_bitrate` in the table `BweTraceInfo` - pub start_bitrate: u32, - /// The field `max_padding_bitrate` in the table `BweTraceInfo` - pub max_padding_bitrate: u32, - /// The field `available_bitrate` in the table `BweTraceInfo` - pub available_bitrate: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for BweTraceInfo { - fn default() -> Self { - Self { - bwe_type: self::BweType::TransportCc, - desired_bitrate: 0, - effective_desired_bitrate: 0, - min_bitrate: 0, - max_bitrate: 0, - start_bitrate: 0, - max_padding_bitrate: 0, - available_bitrate: 0, - } - } - } - - impl BweTraceInfo { - /// Creates a [BweTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BweTraceInfoBuilder<()> { - BweTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_bwe_type: impl ::planus::WriteAsDefault, - field_desired_bitrate: impl ::planus::WriteAsDefault, - field_effective_desired_bitrate: impl ::planus::WriteAsDefault, - field_min_bitrate: impl ::planus::WriteAsDefault, - field_max_bitrate: impl ::planus::WriteAsDefault, - field_start_bitrate: impl ::planus::WriteAsDefault, - field_max_padding_bitrate: impl ::planus::WriteAsDefault, - field_available_bitrate: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_bwe_type = - field_bwe_type.prepare(builder, &self::BweType::TransportCc); - let prepared_desired_bitrate = field_desired_bitrate.prepare(builder, &0); - let prepared_effective_desired_bitrate = - field_effective_desired_bitrate.prepare(builder, &0); - let prepared_min_bitrate = field_min_bitrate.prepare(builder, &0); - let prepared_max_bitrate = field_max_bitrate.prepare(builder, &0); - let prepared_start_bitrate = field_start_bitrate.prepare(builder, &0); - let prepared_max_padding_bitrate = - field_max_padding_bitrate.prepare(builder, &0); - let prepared_available_bitrate = field_available_bitrate.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - if prepared_desired_bitrate.is_some() { - table_writer.write_entry::(1); - } - if prepared_effective_desired_bitrate.is_some() { - table_writer.write_entry::(2); - } - if prepared_min_bitrate.is_some() { - table_writer.write_entry::(3); - } - if prepared_max_bitrate.is_some() { - table_writer.write_entry::(4); - } - if prepared_start_bitrate.is_some() { - table_writer.write_entry::(5); - } - if prepared_max_padding_bitrate.is_some() { - table_writer.write_entry::(6); - } - if prepared_available_bitrate.is_some() { - table_writer.write_entry::(7); - } - if prepared_bwe_type.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_desired_bitrate) = - prepared_desired_bitrate - { - object_writer.write::<_, _, 4>(&prepared_desired_bitrate); - } - if let ::core::option::Option::Some( - prepared_effective_desired_bitrate, - ) = prepared_effective_desired_bitrate - { - object_writer.write::<_, _, 4>(&prepared_effective_desired_bitrate); - } - if let ::core::option::Option::Some(prepared_min_bitrate) = - prepared_min_bitrate - { - object_writer.write::<_, _, 4>(&prepared_min_bitrate); - } - if let ::core::option::Option::Some(prepared_max_bitrate) = - prepared_max_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_bitrate); - } - if let ::core::option::Option::Some(prepared_start_bitrate) = - prepared_start_bitrate - { - object_writer.write::<_, _, 4>(&prepared_start_bitrate); - } - if let ::core::option::Option::Some(prepared_max_padding_bitrate) = - prepared_max_padding_bitrate - { - object_writer.write::<_, _, 4>(&prepared_max_padding_bitrate); - } - if let ::core::option::Option::Some(prepared_available_bitrate) = - prepared_available_bitrate - { - object_writer.write::<_, _, 4>(&prepared_available_bitrate); - } - if let ::core::option::Option::Some(prepared_bwe_type) = - prepared_bwe_type - { - object_writer.write::<_, _, 1>(&prepared_bwe_type); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for BweTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for BweTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for BweTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - BweTraceInfo::create( - builder, - self.bwe_type, - self.desired_bitrate, - self.effective_desired_bitrate, - self.min_bitrate, - self.max_bitrate, - self.start_bitrate, - self.max_padding_bitrate, - self.available_bitrate, - ) - } - } - - /// Builder for serializing an instance of the [BweTraceInfo] type. - /// - /// Can be created using the [BweTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BweTraceInfoBuilder(State); - - impl BweTraceInfoBuilder<()> { - /// Setter for the [`bwe_type` field](BweTraceInfo#structfield.bwe_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn bwe_type(self, value: T0) -> BweTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - BweTraceInfoBuilder((value,)) - } - - /// Sets the [`bwe_type` field](BweTraceInfo#structfield.bwe_type) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bwe_type_as_default(self) -> BweTraceInfoBuilder<(::planus::DefaultValue,)> { - self.bwe_type(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0,)> { - /// Setter for the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn desired_bitrate(self, value: T1) -> BweTraceInfoBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - BweTraceInfoBuilder((v0, value)) - } - - /// Sets the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn desired_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, ::planus::DefaultValue)> { - self.desired_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1)> { - /// Setter for the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn effective_desired_bitrate( - self, - value: T2, - ) -> BweTraceInfoBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - BweTraceInfoBuilder((v0, v1, value)) - } - - /// Sets the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn effective_desired_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, T1, ::planus::DefaultValue)> { - self.effective_desired_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1, T2)> { - /// Setter for the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_bitrate(self, value: T3) -> BweTraceInfoBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - BweTraceInfoBuilder((v0, v1, v2, value)) - } - - /// Sets the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.min_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_bitrate(self, value: T4) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - BweTraceInfoBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.max_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn start_bitrate( - self, - value: T5, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - BweTraceInfoBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn start_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.start_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_padding_bitrate( - self, - value: T6, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - BweTraceInfoBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn max_padding_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.max_padding_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate). - #[inline] - #[allow(clippy::type_complexity)] - pub fn available_bitrate( - self, - value: T7, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - BweTraceInfoBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn available_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.available_bitrate(::planus::DefaultValue) - } - } - - impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BweTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - BweTraceInfo::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [BweTraceInfo]. - #[derive(Copy, Clone)] - pub struct BweTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BweTraceInfoRef<'a> { - /// Getter for the [`bwe_type` field](BweTraceInfo#structfield.bwe_type). - #[inline] - pub fn bwe_type(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "BweTraceInfo", "bwe_type")? - .unwrap_or(self::BweType::TransportCc), - ) - } - - /// Getter for the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate). - #[inline] - pub fn desired_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "BweTraceInfo", "desired_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate). - #[inline] - pub fn effective_desired_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "BweTraceInfo", "effective_desired_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate). - #[inline] - pub fn min_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "BweTraceInfo", "min_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate). - #[inline] - pub fn max_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "BweTraceInfo", "max_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate). - #[inline] - pub fn start_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "BweTraceInfo", "start_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate). - #[inline] - pub fn max_padding_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "BweTraceInfo", "max_padding_bitrate")? - .unwrap_or(0), - ) - } - - /// Getter for the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate). - #[inline] - pub fn available_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "BweTraceInfo", "available_bitrate")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for BweTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BweTraceInfoRef"); - f.field("bwe_type", &self.bwe_type()); - f.field("desired_bitrate", &self.desired_bitrate()); - f.field( - "effective_desired_bitrate", - &self.effective_desired_bitrate(), - ); - f.field("min_bitrate", &self.min_bitrate()); - f.field("max_bitrate", &self.max_bitrate()); - f.field("start_bitrate", &self.start_bitrate()); - f.field("max_padding_bitrate", &self.max_padding_bitrate()); - f.field("available_bitrate", &self.available_bitrate()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for BweTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: BweTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - bwe_type: ::core::convert::TryInto::try_into(value.bwe_type()?)?, - desired_bitrate: ::core::convert::TryInto::try_into( - value.desired_bitrate()?, - )?, - effective_desired_bitrate: ::core::convert::TryInto::try_into( - value.effective_desired_bitrate()?, - )?, - min_bitrate: ::core::convert::TryInto::try_into(value.min_bitrate()?)?, - max_bitrate: ::core::convert::TryInto::try_into(value.max_bitrate()?)?, - start_bitrate: ::core::convert::TryInto::try_into(value.start_bitrate()?)?, - max_padding_bitrate: ::core::convert::TryInto::try_into( - value.max_padding_bitrate()?, - )?, - available_bitrate: ::core::convert::TryInto::try_into( - value.available_bitrate()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for BweTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for BweTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[BweTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for BweTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for BweTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[BweTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `TraceNotification` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:236` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct TraceNotification { - /// The field `type` in the table `TraceNotification` - pub type_: self::TraceEventType, - /// The field `timestamp` in the table `TraceNotification` - pub timestamp: u64, - /// The field `direction` in the table `TraceNotification` - pub direction: super::common::TraceDirection, - /// The field `info` in the table `TraceNotification` - pub info: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for TraceNotification { - fn default() -> Self { - Self { - type_: self::TraceEventType::Probation, - timestamp: 0, - direction: super::common::TraceDirection::DirectionIn, - info: ::core::default::Default::default(), - } - } - } - - impl TraceNotification { - /// Creates a [TraceNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceNotificationBuilder<()> { - TraceNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault< - self::TraceEventType, - self::TraceEventType, - >, - field_timestamp: impl ::planus::WriteAsDefault, - field_direction: impl ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - field_info: impl ::planus::WriteAsOptionalUnion, - ) -> ::planus::Offset { - let prepared_type_ = - field_type_.prepare(builder, &self::TraceEventType::Probation); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = field_direction - .prepare(builder, &super::common::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(1); - } - if prepared_info.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_type_.is_some() { - table_writer.write_entry::(0); - } - if prepared_direction.is_some() { - table_writer.write_entry::(2); - } - if prepared_info.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - object_writer.write::<_, _, 4>(&prepared_info.offset()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_direction) = - prepared_direction - { - object_writer.write::<_, _, 1>(&prepared_direction); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - object_writer.write::<_, _, 1>(&prepared_info.tag()); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for TraceNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for TraceNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - TraceNotification::create( - builder, - self.type_, - self.timestamp, - self.direction, - &self.info, - ) - } - } - - /// Builder for serializing an instance of the [TraceNotification] type. - /// - /// Can be created using the [TraceNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TraceNotificationBuilder(State); - - impl TraceNotificationBuilder<()> { - /// Setter for the [`type` field](TraceNotification#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - TraceNotificationBuilder((value,)) - } - - /// Sets the [`type` field](TraceNotification#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> TraceNotificationBuilder<(::planus::DefaultValue,)> { - self.type_(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0,)> { - /// Setter for the [`timestamp` field](TraceNotification#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T1) -> TraceNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - TraceNotificationBuilder((v0, value)) - } - - /// Sets the [`timestamp` field](TraceNotification#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default( - self, - ) -> TraceNotificationBuilder<(T0, ::planus::DefaultValue)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0, T1)> { - /// Setter for the [`direction` field](TraceNotification#structfield.direction). - #[inline] - #[allow(clippy::type_complexity)] - pub fn direction(self, value: T2) -> TraceNotificationBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - { - let (v0, v1) = self.0; - TraceNotificationBuilder((v0, v1, value)) - } - - /// Sets the [`direction` field](TraceNotification#structfield.direction) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn direction_as_default( - self, - ) -> TraceNotificationBuilder<(T0, T1, ::planus::DefaultValue)> { - self.direction(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0, T1, T2)> { - /// Setter for the [`info` field](TraceNotification#structfield.info). - #[inline] - #[allow(clippy::type_complexity)] - pub fn info(self, value: T3) -> TraceNotificationBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptionalUnion, - { - let (v0, v1, v2) = self.0; - TraceNotificationBuilder((v0, v1, v2, value)) - } - - /// Sets the [`info` field](TraceNotification#structfield.info) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn info_as_null(self) -> TraceNotificationBuilder<(T0, T1, T2, ())> { - self.info(()) - } - } - - impl TraceNotificationBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TraceNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAs<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOffset - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - TraceNotification::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [TraceNotification]. - #[derive(Copy, Clone)] - pub struct TraceNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TraceNotificationRef<'a> { - /// Getter for the [`type` field](TraceNotification#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "TraceNotification", "type_")? - .unwrap_or(self::TraceEventType::Probation), - ) - } - - /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "TraceNotification", "timestamp")? - .unwrap_or(0), - ) - } - - /// Getter for the [`direction` field](TraceNotification#structfield.direction). - #[inline] - pub fn direction(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "TraceNotification", "direction")? - .unwrap_or(super::common::TraceDirection::DirectionIn), - ) - } - - /// Getter for the [`info` field](TraceNotification#structfield.info). - #[inline] - pub fn info( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access_union(3, "TraceNotification", "info") - } - } - - impl<'a> ::core::fmt::Debug for TraceNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("TraceNotificationRef"); - f.field("type_", &self.type_()); - f.field("timestamp", &self.timestamp()); - f.field("direction", &self.direction()); - if let ::core::option::Option::Some(field_info) = self.info().transpose() { - f.field("info", &field_info); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for TraceNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: TraceNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - direction: ::core::convert::TryInto::try_into(value.direction()?)?, - info: if let ::core::option::Option::Some(info) = value.info()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(info)?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for TraceNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[TraceNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for TraceNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for TraceNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[TraceNotificationRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.SctpAssociation` - /// - /// Generated from these locations: - /// * File `../worker/fbs/sctpAssociation.fbs` - pub mod sctp_association { - /// The enum `SctpState` in the namespace `FBS.SctpAssociation` - /// - /// Generated from these locations: - /// * Enum `SctpState` in the file `../worker/fbs/sctpAssociation.fbs:3` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum SctpState { - /// The variant `NEW` in the enum `SctpState` - New = 0, - - /// The variant `CONNECTING` in the enum `SctpState` - Connecting = 1, - - /// The variant `CONNECTED` in the enum `SctpState` - Connected = 2, - - /// The variant `FAILED` in the enum `SctpState` - Failed = 3, - - /// The variant `CLOSED` in the enum `SctpState` - Closed = 4, - } - - impl SctpState { - /// Array containing all valid variants of SctpState - pub const ENUM_VALUES: [Self; 5] = [ - Self::New, - Self::Connecting, - Self::Connected, - Self::Failed, - Self::Closed, - ]; - } - - impl ::core::convert::TryFrom for SctpState { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(SctpState::New), - 1 => ::core::result::Result::Ok(SctpState::Connecting), - 2 => ::core::result::Result::Ok(SctpState::Connected), - 3 => ::core::result::Result::Ok(SctpState::Failed), - 4 => ::core::result::Result::Ok(SctpState::Closed), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: SctpState) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for SctpState { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for SctpState { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for SctpState { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> SctpState { - *self - } - } - - impl ::planus::WriteAsDefault for SctpState { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &SctpState, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for SctpState { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for SctpState { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for SctpState { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "SctpState", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for SctpState { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - } - /// The namespace `FBS.SrtpParameters` - /// - /// Generated from these locations: - /// * File `../worker/fbs/srtpParameters.fbs` - pub mod srtp_parameters { - /// The enum `SrtpCryptoSuite` in the namespace `FBS.SrtpParameters` - /// - /// Generated from these locations: - /// * Enum `SrtpCryptoSuite` in the file `../worker/fbs/srtpParameters.fbs:3` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum SrtpCryptoSuite { - /// The variant `AEAD_AES_256_GCM` in the enum `SrtpCryptoSuite` - AeadAes256Gcm = 0, - - /// The variant `AEAD_AES_128_GCM` in the enum `SrtpCryptoSuite` - AeadAes128Gcm = 1, - - /// The variant `AES_CM_128_HMAC_SHA1_80` in the enum `SrtpCryptoSuite` - AesCm128HmacSha180 = 2, - - /// The variant `AES_CM_128_HMAC_SHA1_32` in the enum `SrtpCryptoSuite` - AesCm128HmacSha132 = 3, - } - - impl SrtpCryptoSuite { - /// Array containing all valid variants of SrtpCryptoSuite - pub const ENUM_VALUES: [Self; 4] = [ - Self::AeadAes256Gcm, - Self::AeadAes128Gcm, - Self::AesCm128HmacSha180, - Self::AesCm128HmacSha132, - ]; - } - - impl ::core::convert::TryFrom for SrtpCryptoSuite { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(SrtpCryptoSuite::AeadAes256Gcm), - 1 => ::core::result::Result::Ok(SrtpCryptoSuite::AeadAes128Gcm), - 2 => ::core::result::Result::Ok(SrtpCryptoSuite::AesCm128HmacSha180), - 3 => ::core::result::Result::Ok(SrtpCryptoSuite::AesCm128HmacSha132), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: SrtpCryptoSuite) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for SrtpCryptoSuite { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for SrtpCryptoSuite { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for SrtpCryptoSuite { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> SrtpCryptoSuite { - *self - } - } - - impl ::planus::WriteAsDefault for SrtpCryptoSuite { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &SrtpCryptoSuite, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for SrtpCryptoSuite { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for SrtpCryptoSuite { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for SrtpCryptoSuite { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "SrtpCryptoSuite", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for SrtpCryptoSuite { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `SrtpParameters` in the namespace `FBS.SrtpParameters` - /// - /// Generated from these locations: - /// * Table `SrtpParameters` in the file `../worker/fbs/srtpParameters.fbs:10` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SrtpParameters { - /// The field `crypto_suite` in the table `SrtpParameters` - pub crypto_suite: self::SrtpCryptoSuite, - /// The field `key_base64` in the table `SrtpParameters` - pub key_base64: ::planus::alloc::string::String, - } - - impl SrtpParameters { - /// Creates a [SrtpParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SrtpParametersBuilder<()> { - SrtpParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_crypto_suite: impl ::planus::WriteAsDefault< - self::SrtpCryptoSuite, - self::SrtpCryptoSuite, - >, - field_key_base64: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_crypto_suite = - field_crypto_suite.prepare(builder, &self::SrtpCryptoSuite::AeadAes256Gcm); - let prepared_key_base64 = field_key_base64.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_crypto_suite.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_key_base64); - if let ::core::option::Option::Some(prepared_crypto_suite) = - prepared_crypto_suite - { - object_writer.write::<_, _, 1>(&prepared_crypto_suite); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SrtpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SrtpParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SrtpParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SrtpParameters::create(builder, self.crypto_suite, &self.key_base64) - } - } - - /// Builder for serializing an instance of the [SrtpParameters] type. - /// - /// Can be created using the [SrtpParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SrtpParametersBuilder(State); - - impl SrtpParametersBuilder<()> { - /// Setter for the [`crypto_suite` field](SrtpParameters#structfield.crypto_suite). - #[inline] - #[allow(clippy::type_complexity)] - pub fn crypto_suite(self, value: T0) -> SrtpParametersBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - SrtpParametersBuilder((value,)) - } - - /// Sets the [`crypto_suite` field](SrtpParameters#structfield.crypto_suite) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn crypto_suite_as_default( - self, - ) -> SrtpParametersBuilder<(::planus::DefaultValue,)> { - self.crypto_suite(::planus::DefaultValue) - } - } - - impl SrtpParametersBuilder<(T0,)> { - /// Setter for the [`key_base64` field](SrtpParameters#structfield.key_base64). - #[inline] - #[allow(clippy::type_complexity)] - pub fn key_base64(self, value: T1) -> SrtpParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - SrtpParametersBuilder((v0, value)) - } - } - - impl SrtpParametersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SrtpParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for SrtpParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for SrtpParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for SrtpParametersBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - SrtpParameters::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [SrtpParameters]. - #[derive(Copy, Clone)] - pub struct SrtpParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SrtpParametersRef<'a> { - /// Getter for the [`crypto_suite` field](SrtpParameters#structfield.crypto_suite). - #[inline] - pub fn crypto_suite(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "SrtpParameters", "crypto_suite")? - .unwrap_or(self::SrtpCryptoSuite::AeadAes256Gcm), - ) - } - - /// Getter for the [`key_base64` field](SrtpParameters#structfield.key_base64). - #[inline] - pub fn key_base64(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "SrtpParameters", "key_base64") - } - } - - impl<'a> ::core::fmt::Debug for SrtpParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SrtpParametersRef"); - f.field("crypto_suite", &self.crypto_suite()); - f.field("key_base64", &self.key_base64()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SrtpParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SrtpParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - crypto_suite: ::core::convert::TryInto::try_into(value.crypto_suite()?)?, - key_base64: ::core::convert::TryInto::try_into(value.key_base64()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SrtpParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SrtpParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SrtpParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SrtpParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SrtpParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SrtpParametersRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Log` - /// - /// Generated from these locations: - /// * File `../worker/fbs/log.fbs` - pub mod log { - /// The table `Log` in the namespace `FBS.Log` - /// - /// Generated from these locations: - /// * Table `Log` in the file `../worker/fbs/log.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Log { - /// The field `data` in the table `Log` - pub data: ::planus::alloc::string::String, - } - - impl Log { - /// Creates a [LogBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> LogBuilder<()> { - LogBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Log { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Log { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Log { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Log::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [Log] type. - /// - /// Can be created using the [Log::builder] method. - #[derive(Debug)] - #[must_use] - pub struct LogBuilder(State); - - impl LogBuilder<()> { - /// Setter for the [`data` field](Log#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> LogBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - LogBuilder((value,)) - } - } - - impl LogBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Log]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> for LogBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> for LogBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> ::planus::WriteAsOffset - for LogBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Log::create(builder, v0) - } - } - - /// Reference to a deserialized [Log]. - #[derive(Copy, Clone)] - pub struct LogRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> LogRef<'a> { - /// Getter for the [`data` field](Log#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Log", "data") - } - } - - impl<'a> ::core::fmt::Debug for LogRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("LogRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Log { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: LogRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: ::core::convert::TryInto::try_into(value.data()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for LogRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for LogRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location("[LogRef]", "get", buffer.offset_from_start) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Log { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for LogRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[LogRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Message` - /// - /// Generated from these locations: - /// * File `../worker/fbs/message.fbs` - pub mod message { - /// The enum `Type` in the namespace `FBS.Message` - /// - /// Generated from these locations: - /// * Enum `Type` in the file `../worker/fbs/message.fbs:8` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum Type { - /// The variant `REQUEST` in the enum `Type` - Request = 0, - - /// The variant `RESPONSE` in the enum `Type` - Response = 1, - - /// The variant `NOTIFICATION` in the enum `Type` - Notification = 2, - - /// The variant `LOG` in the enum `Type` - Log = 3, - } - - impl Type { - /// Array containing all valid variants of Type - pub const ENUM_VALUES: [Self; 4] = - [Self::Request, Self::Response, Self::Notification, Self::Log]; - } - - impl ::core::convert::TryFrom for Type { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(Type::Request), - 1 => ::core::result::Result::Ok(Type::Response), - 2 => ::core::result::Result::Ok(Type::Notification), - 3 => ::core::result::Result::Ok(Type::Log), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: Type) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for Type { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for Type { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for Type { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { - *self - } - } - - impl ::planus::WriteAsDefault for Type { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &Type, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for Type { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for Type { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for Type { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "Type", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for Type { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The union `Body` in the namespace `FBS.Message` - /// - /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/message.fbs:15` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub enum Body { - /// The variant `Request` in the union `Body` - Request(::planus::alloc::boxed::Box), - - /// The variant `Response` in the union `Body` - Response(::planus::alloc::boxed::Box), - - /// The variant `Notification` in the union `Body` - Notification(::planus::alloc::boxed::Box), - - /// The variant `Log` in the union `Body` - Log(::planus::alloc::boxed::Box), - } - - impl Body { - /// Creates a [BodyBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BodyBuilder<::planus::Uninitialized> { - BodyBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_log( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for Body { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::Request(value) => Self::create_request(builder, value), - Self::Response(value) => Self::create_response(builder, value), - Self::Notification(value) => Self::create_notification(builder, value), - Self::Log(value) => Self::create_log(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for Body { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [Body] type. - /// - /// Can be created using the [Body::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BodyBuilder(T); - - impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`Request` variant](Body#variant.Request). - #[inline] - pub fn request(self, value: T) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Response` variant](Body#variant.Response). - #[inline] - pub fn response(self, value: T) -> BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Notification` variant](Body#variant.Notification). - #[inline] - pub fn notification(self, value: T) -> BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Log` variant](Body#variant.Log). - #[inline] - pub fn log(self, value: T) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - } - - impl BodyBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - Request(super::request::RequestRef<'a>), - Response(super::response::ResponseRef<'a>), - Notification(super::notification::NotificationRef<'a>), - Log(super::log::LogRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; - - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::Request(value) => Self::Request(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), - - BodyRef::Response(value) => { - Self::Response(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::Notification(value) => { - Self::Notification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::Log(value) => Self::Log(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for BodyRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::Request( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::Response( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::Notification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::Log( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `Message` in the namespace `FBS.Message` - /// - /// Generated from these locations: - /// * Table `Message` in the file `../worker/fbs/message.fbs:22` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Message { - /// The field `type` in the table `Message` - pub type_: self::Type, - /// The field `data` in the table `Message` - pub data: self::Body, - } - - impl Message { - /// Creates a [MessageBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> MessageBuilder<()> { - MessageBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAsUnion, - ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder, &self::Type::Request); - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(2); - if prepared_type_.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data.offset()); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - object_writer.write::<_, _, 1>(&prepared_data.tag()); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Message { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Message { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Message { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Message::create(builder, self.type_, &self.data) - } - } - - /// Builder for serializing an instance of the [Message] type. - /// - /// Can be created using the [Message::builder] method. - #[derive(Debug)] - #[must_use] - pub struct MessageBuilder(State); - - impl MessageBuilder<()> { - /// Setter for the [`type` field](Message#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> MessageBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - MessageBuilder((value,)) - } - - /// Sets the [`type` field](Message#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default(self) -> MessageBuilder<(::planus::DefaultValue,)> { - self.type_(::planus::DefaultValue) - } - } - - impl MessageBuilder<(T0,)> { - /// Setter for the [`data` field](Message#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> MessageBuilder<(T0, T1)> - where - T1: ::planus::WriteAsUnion, - { - let (v0,) = self.0; - MessageBuilder((v0, value)) - } - } - - impl MessageBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Message]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAs<::planus::Offset> for MessageBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for MessageBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOffset for MessageBuilder<(T0, T1)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - Message::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [Message]. - #[derive(Copy, Clone)] - pub struct MessageRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> MessageRef<'a> { - /// Getter for the [`type` field](Message#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "Message", "type_")? - .unwrap_or(self::Type::Request), - ) - } - - /// Getter for the [`data` field](Message#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_union_required(1, "Message", "data") - } - } - - impl<'a> ::core::fmt::Debug for MessageRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("MessageRef"); - f.field("type_", &self.type_()); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Message { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: MessageRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - data: ::core::convert::TryInto::try_into(value.data()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for MessageRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for MessageRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[MessageRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Message { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for MessageRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[MessageRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Notification` - /// - /// Generated from these locations: - /// * File `../worker/fbs/notification.fbs` - pub mod notification { - /// The enum `Event` in the namespace `FBS.Notification` - /// - /// Generated from these locations: - /// * Enum `Event` in the file `../worker/fbs/notification.fbs:13` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum Event { - /// The variant `TRANSPORT_SEND_RTCP` in the enum `Event` - TransportSendRtcp = 0, - - /// The variant `PRODUCER_SEND` in the enum `Event` - ProducerSend = 1, - - /// The variant `DATAPRODUCER_SEND` in the enum `Event` - DataproducerSend = 2, - - /// The variant `WORKER_RUNNING` in the enum `Event` - WorkerRunning = 3, - - /// The variant `TRANSPORT_SCTP_STATE_CHANGE` in the enum `Event` - TransportSctpStateChange = 4, - - /// The variant `TRANSPORT_TRACE` in the enum `Event` - TransportTrace = 5, - - /// The variant `WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE` in the enum `Event` - WebrtctransportIceSelectedTupleChange = 6, - - /// The variant `WEBRTCTRANSPORT_ICE_STATE_CHANGE` in the enum `Event` - WebrtctransportIceStateChange = 7, - - /// The variant `WEBRTCTRANSPORT_DTLS_STATE_CHANGE` in the enum `Event` - WebrtctransportDtlsStateChange = 8, - - /// The variant `PLAINTRANSPORT_TUPLE` in the enum `Event` - PlaintransportTuple = 9, - - /// The variant `PLAINTRANSPORT_RTCP_TUPLE` in the enum `Event` - PlaintransportRtcpTuple = 10, - - /// The variant `DIRECTTRANSPORT_RTCP` in the enum `Event` - DirecttransportRtcp = 11, - - /// The variant `PRODUCER_SCORE` in the enum `Event` - ProducerScore = 12, - - /// The variant `PRODUCER_TRACE` in the enum `Event` - ProducerTrace = 13, - - /// The variant `PRODUCER_VIDEO_ORIENTATION_CHANGE` in the enum `Event` - ProducerVideoOrientationChange = 14, - - /// The variant `CONSUMER_PRODUCER_PAUSE` in the enum `Event` - ConsumerProducerPause = 15, - - /// The variant `CONSUMER_PRODUCER_RESUME` in the enum `Event` - ConsumerProducerResume = 16, - - /// The variant `CONSUMER_PRODUCER_CLOSE` in the enum `Event` - ConsumerProducerClose = 17, - - /// The variant `CONSUMER_LAYERS_CHANGE` in the enum `Event` - ConsumerLayersChange = 18, - - /// The variant `CONSUMER_RTP` in the enum `Event` - ConsumerRtp = 19, - - /// The variant `CONSUMER_SCORE` in the enum `Event` - ConsumerScore = 20, - - /// The variant `CONSUMER_TRACE` in the enum `Event` - ConsumerTrace = 21, - - /// The variant `DATACONSUMER_BUFFERED_AMOUNT_LOW` in the enum `Event` - DataconsumerBufferedAmountLow = 22, - - /// The variant `DATACONSUMER_SCTP_SENDBUFFER_FULL` in the enum `Event` - DataconsumerSctpSendbufferFull = 23, - - /// The variant `DATACONSUMER_DATAPRODUCER_PAUSE` in the enum `Event` - DataconsumerDataproducerPause = 24, - - /// The variant `DATACONSUMER_DATAPRODUCER_RESUME` in the enum `Event` - DataconsumerDataproducerResume = 25, - - /// The variant `DATACONSUMER_DATAPRODUCER_CLOSE` in the enum `Event` - DataconsumerDataproducerClose = 26, - - /// The variant `DATACONSUMER_MESSAGE` in the enum `Event` - DataconsumerMessage = 27, - - /// The variant `ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER` in the enum `Event` - ActivespeakerobserverDominantSpeaker = 28, - - /// The variant `AUDIOLEVELOBSERVER_SILENCE` in the enum `Event` - AudiolevelobserverSilence = 29, - - /// The variant `AUDIOLEVELOBSERVER_VOLUMES` in the enum `Event` - AudiolevelobserverVolumes = 30, - } - - impl Event { - /// Array containing all valid variants of Event - pub const ENUM_VALUES: [Self; 31] = [ - Self::TransportSendRtcp, - Self::ProducerSend, - Self::DataproducerSend, - Self::WorkerRunning, - Self::TransportSctpStateChange, - Self::TransportTrace, - Self::WebrtctransportIceSelectedTupleChange, - Self::WebrtctransportIceStateChange, - Self::WebrtctransportDtlsStateChange, - Self::PlaintransportTuple, - Self::PlaintransportRtcpTuple, - Self::DirecttransportRtcp, - Self::ProducerScore, - Self::ProducerTrace, - Self::ProducerVideoOrientationChange, - Self::ConsumerProducerPause, - Self::ConsumerProducerResume, - Self::ConsumerProducerClose, - Self::ConsumerLayersChange, - Self::ConsumerRtp, - Self::ConsumerScore, - Self::ConsumerTrace, - Self::DataconsumerBufferedAmountLow, - Self::DataconsumerSctpSendbufferFull, - Self::DataconsumerDataproducerPause, - Self::DataconsumerDataproducerResume, - Self::DataconsumerDataproducerClose, - Self::DataconsumerMessage, - Self::ActivespeakerobserverDominantSpeaker, - Self::AudiolevelobserverSilence, - Self::AudiolevelobserverVolumes, - ]; - } - - impl ::core::convert::TryFrom for Event { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(Event::TransportSendRtcp), - 1 => ::core::result::Result::Ok(Event::ProducerSend), - 2 => ::core::result::Result::Ok(Event::DataproducerSend), - 3 => ::core::result::Result::Ok(Event::WorkerRunning), - 4 => ::core::result::Result::Ok(Event::TransportSctpStateChange), - 5 => ::core::result::Result::Ok(Event::TransportTrace), - 6 => { - ::core::result::Result::Ok(Event::WebrtctransportIceSelectedTupleChange) - } - 7 => ::core::result::Result::Ok(Event::WebrtctransportIceStateChange), - 8 => ::core::result::Result::Ok(Event::WebrtctransportDtlsStateChange), - 9 => ::core::result::Result::Ok(Event::PlaintransportTuple), - 10 => ::core::result::Result::Ok(Event::PlaintransportRtcpTuple), - 11 => ::core::result::Result::Ok(Event::DirecttransportRtcp), - 12 => ::core::result::Result::Ok(Event::ProducerScore), - 13 => ::core::result::Result::Ok(Event::ProducerTrace), - 14 => ::core::result::Result::Ok(Event::ProducerVideoOrientationChange), - 15 => ::core::result::Result::Ok(Event::ConsumerProducerPause), - 16 => ::core::result::Result::Ok(Event::ConsumerProducerResume), - 17 => ::core::result::Result::Ok(Event::ConsumerProducerClose), - 18 => ::core::result::Result::Ok(Event::ConsumerLayersChange), - 19 => ::core::result::Result::Ok(Event::ConsumerRtp), - 20 => ::core::result::Result::Ok(Event::ConsumerScore), - 21 => ::core::result::Result::Ok(Event::ConsumerTrace), - 22 => ::core::result::Result::Ok(Event::DataconsumerBufferedAmountLow), - 23 => ::core::result::Result::Ok(Event::DataconsumerSctpSendbufferFull), - 24 => ::core::result::Result::Ok(Event::DataconsumerDataproducerPause), - 25 => ::core::result::Result::Ok(Event::DataconsumerDataproducerResume), - 26 => ::core::result::Result::Ok(Event::DataconsumerDataproducerClose), - 27 => ::core::result::Result::Ok(Event::DataconsumerMessage), - 28 => { - ::core::result::Result::Ok(Event::ActivespeakerobserverDominantSpeaker) - } - 29 => ::core::result::Result::Ok(Event::AudiolevelobserverSilence), - 30 => ::core::result::Result::Ok(Event::AudiolevelobserverVolumes), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: Event) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for Event { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for Event { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for Event { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Event { - *self - } - } - - impl ::planus::WriteAsDefault for Event { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &Event, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for Event { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for Event { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for Event { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "Event", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for Event { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The union `Body` in the namespace `FBS.Notification` - /// - /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/notification.fbs:50` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub enum Body { - /// The variant `Transport_SendRtcpNotification` in the union `Body` - TransportSendRtcpNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_SctpStateChangeNotification` in the union `Body` - TransportSctpStateChangeNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Producer_SendNotification` in the union `Body` - ProducerSendNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataProducer_SendNotification` in the union `Body` - DataProducerSendNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_TraceNotification` in the union `Body` - TransportTraceNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `WebRtcTransport_IceSelectedTupleChangeNotification` in the union `Body` - WebRtcTransportIceSelectedTupleChangeNotification( - ::planus::alloc::boxed::Box< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - ), - - /// The variant `WebRtcTransport_IceStateChangeNotification` in the union `Body` - WebRtcTransportIceStateChangeNotification( - ::planus::alloc::boxed::Box< - super::web_rtc_transport::IceStateChangeNotification, - >, - ), - - /// The variant `WebRtcTransport_DtlsStateChangeNotification` in the union `Body` - WebRtcTransportDtlsStateChangeNotification( - ::planus::alloc::boxed::Box< - super::web_rtc_transport::DtlsStateChangeNotification, - >, - ), - - /// The variant `PlainTransport_TupleNotification` in the union `Body` - PlainTransportTupleNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PlainTransport_RtcpTupleNotification` in the union `Body` - PlainTransportRtcpTupleNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DirectTransport_RtcpNotification` in the union `Body` - DirectTransportRtcpNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Producer_ScoreNotification` in the union `Body` - ProducerScoreNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Producer_TraceNotification` in the union `Body` - ProducerTraceNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Producer_VideoOrientationChangeNotification` in the union `Body` - ProducerVideoOrientationChangeNotification( - ::planus::alloc::boxed::Box< - super::producer::VideoOrientationChangeNotification, - >, - ), - - /// The variant `Consumer_LayersChangeNotification` in the union `Body` - ConsumerLayersChangeNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_RtpNotification` in the union `Body` - ConsumerRtpNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_ScoreNotification` in the union `Body` - ConsumerScoreNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_TraceNotification` in the union `Body` - ConsumerTraceNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_MessageNotification` in the union `Body` - DataConsumerMessageNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_BufferedAmountLowNotification` in the union `Body` - DataConsumerBufferedAmountLowNotification( - ::planus::alloc::boxed::Box< - super::data_consumer::BufferedAmountLowNotification, - >, - ), - - /// The variant `ActiveSpeakerObserver_DominantSpeakerNotification` in the union `Body` - ActiveSpeakerObserverDominantSpeakerNotification( - ::planus::alloc::boxed::Box< - super::active_speaker_observer::DominantSpeakerNotification, - >, - ), - - /// The variant `AudioLevelObserver_VolumesNotification` in the union `Body` - AudioLevelObserverVolumesNotification( - ::planus::alloc::boxed::Box, - ), - } - - impl Body { - /// Creates a [BodyBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BodyBuilder<::planus::Uninitialized> { - BodyBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_transport_send_rtcp_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_sctp_state_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_send_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_producer_send_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_trace_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_ice_selected_tuple_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_ice_state_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::web_rtc_transport::IceStateChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_dtls_state_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::web_rtc_transport::DtlsStateChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_plain_transport_tuple_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_plain_transport_rtcp_tuple_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_direct_transport_rtcp_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_score_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_trace_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_video_orientation_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::producer::VideoOrientationChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_layers_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_rtp_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_score_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_trace_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_message_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_buffered_amount_low_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::data_consumer::BufferedAmountLowNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_active_speaker_observer_dominant_speaker_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_audio_level_observer_volumes_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::audio_level_observer::VolumesNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for Body { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::TransportSendRtcpNotification(value) => { - Self::create_transport_send_rtcp_notification(builder, value) - } - Self::TransportSctpStateChangeNotification(value) => { - Self::create_transport_sctp_state_change_notification(builder, value) - } - Self::ProducerSendNotification(value) => { - Self::create_producer_send_notification(builder, value) - } - Self::DataProducerSendNotification(value) => { - Self::create_data_producer_send_notification(builder, value) - } - Self::TransportTraceNotification(value) => { - Self::create_transport_trace_notification(builder, value) - } - Self::WebRtcTransportIceSelectedTupleChangeNotification(value) => { - Self::create_web_rtc_transport_ice_selected_tuple_change_notification( - builder, value, - ) - } - Self::WebRtcTransportIceStateChangeNotification(value) => { - Self::create_web_rtc_transport_ice_state_change_notification( - builder, value, - ) - } - Self::WebRtcTransportDtlsStateChangeNotification(value) => { - Self::create_web_rtc_transport_dtls_state_change_notification( - builder, value, - ) - } - Self::PlainTransportTupleNotification(value) => { - Self::create_plain_transport_tuple_notification(builder, value) - } - Self::PlainTransportRtcpTupleNotification(value) => { - Self::create_plain_transport_rtcp_tuple_notification(builder, value) - } - Self::DirectTransportRtcpNotification(value) => { - Self::create_direct_transport_rtcp_notification(builder, value) - } - Self::ProducerScoreNotification(value) => { - Self::create_producer_score_notification(builder, value) - } - Self::ProducerTraceNotification(value) => { - Self::create_producer_trace_notification(builder, value) - } - Self::ProducerVideoOrientationChangeNotification(value) => { - Self::create_producer_video_orientation_change_notification( - builder, value, - ) - } - Self::ConsumerLayersChangeNotification(value) => { - Self::create_consumer_layers_change_notification(builder, value) - } - Self::ConsumerRtpNotification(value) => { - Self::create_consumer_rtp_notification(builder, value) - } - Self::ConsumerScoreNotification(value) => { - Self::create_consumer_score_notification(builder, value) - } - Self::ConsumerTraceNotification(value) => { - Self::create_consumer_trace_notification(builder, value) - } - Self::DataConsumerMessageNotification(value) => { - Self::create_data_consumer_message_notification(builder, value) - } - Self::DataConsumerBufferedAmountLowNotification(value) => { - Self::create_data_consumer_buffered_amount_low_notification( - builder, value, - ) - } - Self::ActiveSpeakerObserverDominantSpeakerNotification(value) => { - Self::create_active_speaker_observer_dominant_speaker_notification( - builder, value, - ) - } - Self::AudioLevelObserverVolumesNotification(value) => { - Self::create_audio_level_observer_volumes_notification(builder, value) - } - } - } - } - - impl ::planus::WriteAsOptionalUnion for Body { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [Body] type. - /// - /// Can be created using the [Body::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BodyBuilder(T); - - impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`Transport_SendRtcpNotification` variant](Body#variant.TransportSendRtcpNotification). - #[inline] - pub fn transport_send_rtcp_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_SctpStateChangeNotification` variant](Body#variant.TransportSctpStateChangeNotification). - #[inline] - pub fn transport_sctp_state_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_SendNotification` variant](Body#variant.ProducerSendNotification). - #[inline] - pub fn producer_send_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataProducer_SendNotification` variant](Body#variant.DataProducerSendNotification). - #[inline] - pub fn data_producer_send_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_TraceNotification` variant](Body#variant.TransportTraceNotification). - #[inline] - pub fn transport_trace_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_IceSelectedTupleChangeNotification` variant](Body#variant.WebRtcTransportIceSelectedTupleChangeNotification). - #[inline] - pub fn web_rtc_transport_ice_selected_tuple_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_IceStateChangeNotification` variant](Body#variant.WebRtcTransportIceStateChangeNotification). - #[inline] - pub fn web_rtc_transport_ice_state_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceStateChangeNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_DtlsStateChangeNotification` variant](Body#variant.WebRtcTransportDtlsStateChangeNotification). - #[inline] - pub fn web_rtc_transport_dtls_state_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::DtlsStateChangeNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PlainTransport_TupleNotification` variant](Body#variant.PlainTransportTupleNotification). - #[inline] - pub fn plain_transport_tuple_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PlainTransport_RtcpTupleNotification` variant](Body#variant.PlainTransportRtcpTupleNotification). - #[inline] - pub fn plain_transport_rtcp_tuple_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DirectTransport_RtcpNotification` variant](Body#variant.DirectTransportRtcpNotification). - #[inline] - pub fn direct_transport_rtcp_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_ScoreNotification` variant](Body#variant.ProducerScoreNotification). - #[inline] - pub fn producer_score_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_TraceNotification` variant](Body#variant.ProducerTraceNotification). - #[inline] - pub fn producer_trace_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_VideoOrientationChangeNotification` variant](Body#variant.ProducerVideoOrientationChangeNotification). - #[inline] - pub fn producer_video_orientation_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_LayersChangeNotification` variant](Body#variant.ConsumerLayersChangeNotification). - #[inline] - pub fn consumer_layers_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_RtpNotification` variant](Body#variant.ConsumerRtpNotification). - #[inline] - pub fn consumer_rtp_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_ScoreNotification` variant](Body#variant.ConsumerScoreNotification). - #[inline] - pub fn consumer_score_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_TraceNotification` variant](Body#variant.ConsumerTraceNotification). - #[inline] - pub fn consumer_trace_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_MessageNotification` variant](Body#variant.DataConsumerMessageNotification). - #[inline] - pub fn data_consumer_message_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_BufferedAmountLowNotification` variant](Body#variant.DataConsumerBufferedAmountLowNotification). - #[inline] - pub fn data_consumer_buffered_amount_low_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`ActiveSpeakerObserver_DominantSpeakerNotification` variant](Body#variant.ActiveSpeakerObserverDominantSpeakerNotification). - #[inline] - pub fn active_speaker_observer_dominant_speaker_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`AudioLevelObserver_VolumesNotification` variant](Body#variant.AudioLevelObserverVolumesNotification). - #[inline] - pub fn audio_level_observer_volumes_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - } - - impl BodyBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - TransportSendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), - TransportSctpStateChangeNotification( - super::transport::SctpStateChangeNotificationRef<'a>, - ), - ProducerSendNotification(super::producer::SendNotificationRef<'a>), - DataProducerSendNotification(super::data_producer::SendNotificationRef<'a>), - TransportTraceNotification(super::transport::TraceNotificationRef<'a>), - WebRtcTransportIceSelectedTupleChangeNotification( - super::web_rtc_transport::IceSelectedTupleChangeNotificationRef<'a>, - ), - WebRtcTransportIceStateChangeNotification( - super::web_rtc_transport::IceStateChangeNotificationRef<'a>, - ), - WebRtcTransportDtlsStateChangeNotification( - super::web_rtc_transport::DtlsStateChangeNotificationRef<'a>, - ), - PlainTransportTupleNotification(super::plain_transport::TupleNotificationRef<'a>), - PlainTransportRtcpTupleNotification( - super::plain_transport::RtcpTupleNotificationRef<'a>, - ), - DirectTransportRtcpNotification(super::direct_transport::RtcpNotificationRef<'a>), - ProducerScoreNotification(super::producer::ScoreNotificationRef<'a>), - ProducerTraceNotification(super::producer::TraceNotificationRef<'a>), - ProducerVideoOrientationChangeNotification( - super::producer::VideoOrientationChangeNotificationRef<'a>, - ), - ConsumerLayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), - ConsumerRtpNotification(super::consumer::RtpNotificationRef<'a>), - ConsumerScoreNotification(super::consumer::ScoreNotificationRef<'a>), - ConsumerTraceNotification(super::consumer::TraceNotificationRef<'a>), - DataConsumerMessageNotification(super::data_consumer::MessageNotificationRef<'a>), - DataConsumerBufferedAmountLowNotification( - super::data_consumer::BufferedAmountLowNotificationRef<'a>, - ), - ActiveSpeakerObserverDominantSpeakerNotification( - super::active_speaker_observer::DominantSpeakerNotificationRef<'a>, - ), - AudioLevelObserverVolumesNotification( - super::audio_level_observer::VolumesNotificationRef<'a>, - ), - } - - impl<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; - - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::TransportSendRtcpNotification(value) => { - Self::TransportSendRtcpNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportSctpStateChangeNotification(value) => { - Self::TransportSctpStateChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::ProducerSendNotification(value) => { - Self::ProducerSendNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataProducerSendNotification(value) => { - Self::DataProducerSendNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportTraceNotification(value) => { - Self::TransportTraceNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WebRtcTransportIceSelectedTupleChangeNotification(value) => { - Self::WebRtcTransportIceSelectedTupleChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::WebRtcTransportIceStateChangeNotification(value) => { - Self::WebRtcTransportIceStateChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::WebRtcTransportDtlsStateChangeNotification(value) => { - Self::WebRtcTransportDtlsStateChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::PlainTransportTupleNotification(value) => { - Self::PlainTransportTupleNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PlainTransportRtcpTupleNotification(value) => { - Self::PlainTransportRtcpTupleNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::DirectTransportRtcpNotification(value) => { - Self::DirectTransportRtcpNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ProducerScoreNotification(value) => { - Self::ProducerScoreNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ProducerTraceNotification(value) => { - Self::ProducerTraceNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ProducerVideoOrientationChangeNotification(value) => { - Self::ProducerVideoOrientationChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::ConsumerLayersChangeNotification(value) => { - Self::ConsumerLayersChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::ConsumerRtpNotification(value) => { - Self::ConsumerRtpNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerScoreNotification(value) => { - Self::ConsumerScoreNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerTraceNotification(value) => { - Self::ConsumerTraceNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerMessageNotification(value) => { - Self::DataConsumerMessageNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerBufferedAmountLowNotification(value) => { - Self::DataConsumerBufferedAmountLowNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::ActiveSpeakerObserverDominantSpeakerNotification(value) => { - Self::ActiveSpeakerObserverDominantSpeakerNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::AudioLevelObserverVolumesNotification(value) => { - Self::AudioLevelObserverVolumesNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for BodyRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::TransportSendRtcpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => { - ::core::result::Result::Ok(Self::TransportSctpStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 3 => ::core::result::Result::Ok(Self::ProducerSendNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::DataProducerSendNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::TransportTraceNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok( - Self::WebRtcTransportIceSelectedTupleChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 7 => ::core::result::Result::Ok( - Self::WebRtcTransportIceStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 8 => ::core::result::Result::Ok( - Self::WebRtcTransportDtlsStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 9 => ::core::result::Result::Ok(Self::PlainTransportTupleNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 10 => { - ::core::result::Result::Ok(Self::PlainTransportRtcpTupleNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 11 => ::core::result::Result::Ok(Self::DirectTransportRtcpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 12 => ::core::result::Result::Ok(Self::ProducerScoreNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 13 => ::core::result::Result::Ok(Self::ProducerTraceNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => ::core::result::Result::Ok( - Self::ProducerVideoOrientationChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 15 => ::core::result::Result::Ok(Self::ConsumerLayersChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 16 => ::core::result::Result::Ok(Self::ConsumerRtpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 17 => ::core::result::Result::Ok(Self::ConsumerScoreNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 18 => ::core::result::Result::Ok(Self::ConsumerTraceNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 19 => ::core::result::Result::Ok(Self::DataConsumerMessageNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 20 => ::core::result::Result::Ok( - Self::DataConsumerBufferedAmountLowNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 21 => ::core::result::Result::Ok( - Self::ActiveSpeakerObserverDominantSpeakerNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 22 => { - ::core::result::Result::Ok(Self::AudioLevelObserverVolumesNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `Notification` in the namespace `FBS.Notification` - /// - /// Generated from these locations: - /// * Table `Notification` in the file `../worker/fbs/notification.fbs:78` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Notification { - /// The field `handler_id` in the table `Notification` - pub handler_id: ::planus::alloc::string::String, - /// The field `event` in the table `Notification` - pub event: self::Event, - /// The field `body` in the table `Notification` - pub body: ::core::option::Option, - } - - impl Notification { - /// Creates a [NotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> NotificationBuilder<()> { - NotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_handler_id: impl ::planus::WriteAs<::planus::Offset>, - field_event: impl ::planus::WriteAsDefault, - field_body: impl ::planus::WriteAsOptionalUnion, - ) -> ::planus::Offset { - let prepared_handler_id = field_handler_id.prepare(builder); - let prepared_event = - field_event.prepare(builder, &self::Event::TransportSendRtcp); - let prepared_body = field_body.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_body.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_event.is_some() { - table_writer.write_entry::(1); - } - if prepared_body.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_handler_id); - if let ::core::option::Option::Some(prepared_body) = prepared_body { - object_writer.write::<_, _, 4>(&prepared_body.offset()); - } - if let ::core::option::Option::Some(prepared_event) = prepared_event { - object_writer.write::<_, _, 1>(&prepared_event); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - object_writer.write::<_, _, 1>(&prepared_body.tag()); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Notification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Notification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Notification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - Notification::create(builder, &self.handler_id, self.event, &self.body) - } - } - - /// Builder for serializing an instance of the [Notification] type. - /// - /// Can be created using the [Notification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct NotificationBuilder(State); - - impl NotificationBuilder<()> { - /// Setter for the [`handler_id` field](Notification#structfield.handler_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn handler_id(self, value: T0) -> NotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - NotificationBuilder((value,)) - } - } - - impl NotificationBuilder<(T0,)> { - /// Setter for the [`event` field](Notification#structfield.event). - #[inline] - #[allow(clippy::type_complexity)] - pub fn event(self, value: T1) -> NotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - NotificationBuilder((v0, value)) - } - - /// Sets the [`event` field](Notification#structfield.event) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn event_as_default(self) -> NotificationBuilder<(T0, ::planus::DefaultValue)> { - self.event(::planus::DefaultValue) - } - } - - impl NotificationBuilder<(T0, T1)> { - /// Setter for the [`body` field](Notification#structfield.body). - #[inline] - #[allow(clippy::type_complexity)] - pub fn body(self, value: T2) -> NotificationBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptionalUnion, - { - let (v0, v1) = self.0; - NotificationBuilder((v0, v1, value)) - } - - /// Sets the [`body` field](Notification#structfield.body) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn body_as_null(self) -> NotificationBuilder<(T0, T1, ())> { - self.body(()) - } - } - - impl NotificationBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Notification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAs<::planus::Offset> - for NotificationBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for NotificationBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOffset for NotificationBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - Notification::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [Notification]. - #[derive(Copy, Clone)] - pub struct NotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> NotificationRef<'a> { - /// Getter for the [`handler_id` field](Notification#structfield.handler_id). - #[inline] - pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Notification", "handler_id") - } - - /// Getter for the [`event` field](Notification#structfield.event). - #[inline] - pub fn event(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "Notification", "event")? - .unwrap_or(self::Event::TransportSendRtcp), - ) - } - - /// Getter for the [`body` field](Notification#structfield.body). - #[inline] - pub fn body(&self) -> ::planus::Result<::core::option::Option>> { - self.0.access_union(2, "Notification", "body") - } - } - - impl<'a> ::core::fmt::Debug for NotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("NotificationRef"); - f.field("handler_id", &self.handler_id()); - f.field("event", &self.event()); - if let ::core::option::Option::Some(field_body) = self.body().transpose() { - f.field("body", &field_body); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Notification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: NotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - handler_id: ::core::convert::TryInto::try_into(value.handler_id()?)?, - event: ::core::convert::TryInto::try_into(value.event()?)?, - body: if let ::core::option::Option::Some(body) = value.body()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(body)?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for NotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for NotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[NotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Notification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for NotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[NotificationRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Request` - /// - /// Generated from these locations: - /// * File `../worker/fbs/request.fbs` - pub mod request { - /// The enum `Method` in the namespace `FBS.Request` - /// - /// Generated from these locations: - /// * Enum `Method` in the file `../worker/fbs/request.fbs:11` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum Method { - /// The variant `WORKER_CLOSE` in the enum `Method` - WorkerClose = 0, - - /// The variant `WORKER_DUMP` in the enum `Method` - WorkerDump = 1, - - /// The variant `WORKER_GET_RESOURCE_USAGE` in the enum `Method` - WorkerGetResourceUsage = 2, - - /// The variant `WORKER_UPDATE_SETTINGS` in the enum `Method` - WorkerUpdateSettings = 3, - - /// The variant `WORKER_CREATE_WEBRTCSERVER` in the enum `Method` - WorkerCreateWebrtcserver = 4, - - /// The variant `WORKER_CREATE_ROUTER` in the enum `Method` - WorkerCreateRouter = 5, - - /// The variant `WORKER_WEBRTCSERVER_CLOSE` in the enum `Method` - WorkerWebrtcserverClose = 6, - - /// The variant `WORKER_CLOSE_ROUTER` in the enum `Method` - WorkerCloseRouter = 7, - - /// The variant `WEBRTCSERVER_DUMP` in the enum `Method` - WebrtcserverDump = 8, - - /// The variant `ROUTER_DUMP` in the enum `Method` - RouterDump = 9, - - /// The variant `ROUTER_CREATE_WEBRTCTRANSPORT` in the enum `Method` - RouterCreateWebrtctransport = 10, - - /// The variant `ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER` in the enum `Method` - RouterCreateWebrtctransportWithServer = 11, - - /// The variant `ROUTER_CREATE_PLAINTRANSPORT` in the enum `Method` - RouterCreatePlaintransport = 12, - - /// The variant `ROUTER_CREATE_PIPETRANSPORT` in the enum `Method` - RouterCreatePipetransport = 13, - - /// The variant `ROUTER_CREATE_DIRECTTRANSPORT` in the enum `Method` - RouterCreateDirecttransport = 14, - - /// The variant `ROUTER_CLOSE_TRANSPORT` in the enum `Method` - RouterCloseTransport = 15, - - /// The variant `ROUTER_CREATE_ACTIVESPEAKEROBSERVER` in the enum `Method` - RouterCreateActivespeakerobserver = 16, - - /// The variant `ROUTER_CREATE_AUDIOLEVELOBSERVER` in the enum `Method` - RouterCreateAudiolevelobserver = 17, - - /// The variant `ROUTER_CLOSE_RTPOBSERVER` in the enum `Method` - RouterCloseRtpobserver = 18, - - /// The variant `TRANSPORT_DUMP` in the enum `Method` - TransportDump = 19, - - /// The variant `TRANSPORT_GET_STATS` in the enum `Method` - TransportGetStats = 20, - - /// The variant `TRANSPORT_CONNECT` in the enum `Method` - TransportConnect = 21, - - /// The variant `TRANSPORT_SET_MAX_INCOMING_BITRATE` in the enum `Method` - TransportSetMaxIncomingBitrate = 22, - - /// The variant `TRANSPORT_SET_MAX_OUTGOING_BITRATE` in the enum `Method` - TransportSetMaxOutgoingBitrate = 23, - - /// The variant `TRANSPORT_SET_MIN_OUTGOING_BITRATE` in the enum `Method` - TransportSetMinOutgoingBitrate = 24, - - /// The variant `TRANSPORT_RESTART_ICE` in the enum `Method` - TransportRestartIce = 25, - - /// The variant `TRANSPORT_PRODUCE` in the enum `Method` - TransportProduce = 26, - - /// The variant `TRANSPORT_PRODUCE_DATA` in the enum `Method` - TransportProduceData = 27, - - /// The variant `TRANSPORT_CONSUME` in the enum `Method` - TransportConsume = 28, - - /// The variant `TRANSPORT_CONSUME_DATA` in the enum `Method` - TransportConsumeData = 29, - - /// The variant `TRANSPORT_ENABLE_TRACE_EVENT` in the enum `Method` - TransportEnableTraceEvent = 30, - - /// The variant `TRANSPORT_CLOSE_PRODUCER` in the enum `Method` - TransportCloseProducer = 31, - - /// The variant `TRANSPORT_CLOSE_CONSUMER` in the enum `Method` - TransportCloseConsumer = 32, - - /// The variant `TRANSPORT_CLOSE_DATAPRODUCER` in the enum `Method` - TransportCloseDataproducer = 33, - - /// The variant `TRANSPORT_CLOSE_DATACONSUMER` in the enum `Method` - TransportCloseDataconsumer = 34, - - /// The variant `PLAINTRANSPORT_CONNECT` in the enum `Method` - PlaintransportConnect = 35, - - /// The variant `PIPETRANSPORT_CONNECT` in the enum `Method` - PipetransportConnect = 36, - - /// The variant `WEBRTCTRANSPORT_CONNECT` in the enum `Method` - WebrtctransportConnect = 37, - - /// The variant `PRODUCER_DUMP` in the enum `Method` - ProducerDump = 38, - - /// The variant `PRODUCER_GET_STATS` in the enum `Method` - ProducerGetStats = 39, - - /// The variant `PRODUCER_PAUSE` in the enum `Method` - ProducerPause = 40, - - /// The variant `PRODUCER_RESUME` in the enum `Method` - ProducerResume = 41, - - /// The variant `PRODUCER_ENABLE_TRACE_EVENT` in the enum `Method` - ProducerEnableTraceEvent = 42, - - /// The variant `CONSUMER_DUMP` in the enum `Method` - ConsumerDump = 43, - - /// The variant `CONSUMER_GET_STATS` in the enum `Method` - ConsumerGetStats = 44, - - /// The variant `CONSUMER_PAUSE` in the enum `Method` - ConsumerPause = 45, - - /// The variant `CONSUMER_RESUME` in the enum `Method` - ConsumerResume = 46, - - /// The variant `CONSUMER_SET_PREFERRED_LAYERS` in the enum `Method` - ConsumerSetPreferredLayers = 47, - - /// The variant `CONSUMER_SET_PRIORITY` in the enum `Method` - ConsumerSetPriority = 48, - - /// The variant `CONSUMER_REQUEST_KEY_FRAME` in the enum `Method` - ConsumerRequestKeyFrame = 49, - - /// The variant `CONSUMER_ENABLE_TRACE_EVENT` in the enum `Method` - ConsumerEnableTraceEvent = 50, - - /// The variant `DATAPRODUCER_DUMP` in the enum `Method` - DataproducerDump = 51, - - /// The variant `DATAPRODUCER_GET_STATS` in the enum `Method` - DataproducerGetStats = 52, - - /// The variant `DATAPRODUCER_PAUSE` in the enum `Method` - DataproducerPause = 53, - - /// The variant `DATAPRODUCER_RESUME` in the enum `Method` - DataproducerResume = 54, - - /// The variant `DATACONSUMER_DUMP` in the enum `Method` - DataconsumerDump = 55, - - /// The variant `DATACONSUMER_GET_STATS` in the enum `Method` - DataconsumerGetStats = 56, - - /// The variant `DATACONSUMER_PAUSE` in the enum `Method` - DataconsumerPause = 57, - - /// The variant `DATACONSUMER_RESUME` in the enum `Method` - DataconsumerResume = 58, - - /// The variant `DATACONSUMER_GET_BUFFERED_AMOUNT` in the enum `Method` - DataconsumerGetBufferedAmount = 59, - - /// The variant `DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD` in the enum `Method` - DataconsumerSetBufferedAmountLowThreshold = 60, - - /// The variant `DATACONSUMER_SEND` in the enum `Method` - DataconsumerSend = 61, - - /// The variant `DATACONSUMER_SET_SUBCHANNELS` in the enum `Method` - DataconsumerSetSubchannels = 62, - - /// The variant `RTPOBSERVER_PAUSE` in the enum `Method` - RtpobserverPause = 63, - - /// The variant `RTPOBSERVER_RESUME` in the enum `Method` - RtpobserverResume = 64, - - /// The variant `RTPOBSERVER_ADD_PRODUCER` in the enum `Method` - RtpobserverAddProducer = 65, - - /// The variant `RTPOBSERVER_REMOVE_PRODUCER` in the enum `Method` - RtpobserverRemoveProducer = 66, - } - - impl Method { - /// Array containing all valid variants of Method - pub const ENUM_VALUES: [Self; 67] = [ - Self::WorkerClose, - Self::WorkerDump, - Self::WorkerGetResourceUsage, - Self::WorkerUpdateSettings, - Self::WorkerCreateWebrtcserver, - Self::WorkerCreateRouter, - Self::WorkerWebrtcserverClose, - Self::WorkerCloseRouter, - Self::WebrtcserverDump, - Self::RouterDump, - Self::RouterCreateWebrtctransport, - Self::RouterCreateWebrtctransportWithServer, - Self::RouterCreatePlaintransport, - Self::RouterCreatePipetransport, - Self::RouterCreateDirecttransport, - Self::RouterCloseTransport, - Self::RouterCreateActivespeakerobserver, - Self::RouterCreateAudiolevelobserver, - Self::RouterCloseRtpobserver, - Self::TransportDump, - Self::TransportGetStats, - Self::TransportConnect, - Self::TransportSetMaxIncomingBitrate, - Self::TransportSetMaxOutgoingBitrate, - Self::TransportSetMinOutgoingBitrate, - Self::TransportRestartIce, - Self::TransportProduce, - Self::TransportProduceData, - Self::TransportConsume, - Self::TransportConsumeData, - Self::TransportEnableTraceEvent, - Self::TransportCloseProducer, - Self::TransportCloseConsumer, - Self::TransportCloseDataproducer, - Self::TransportCloseDataconsumer, - Self::PlaintransportConnect, - Self::PipetransportConnect, - Self::WebrtctransportConnect, - Self::ProducerDump, - Self::ProducerGetStats, - Self::ProducerPause, - Self::ProducerResume, - Self::ProducerEnableTraceEvent, - Self::ConsumerDump, - Self::ConsumerGetStats, - Self::ConsumerPause, - Self::ConsumerResume, - Self::ConsumerSetPreferredLayers, - Self::ConsumerSetPriority, - Self::ConsumerRequestKeyFrame, - Self::ConsumerEnableTraceEvent, - Self::DataproducerDump, - Self::DataproducerGetStats, - Self::DataproducerPause, - Self::DataproducerResume, - Self::DataconsumerDump, - Self::DataconsumerGetStats, - Self::DataconsumerPause, - Self::DataconsumerResume, - Self::DataconsumerGetBufferedAmount, - Self::DataconsumerSetBufferedAmountLowThreshold, - Self::DataconsumerSend, - Self::DataconsumerSetSubchannels, - Self::RtpobserverPause, - Self::RtpobserverResume, - Self::RtpobserverAddProducer, - Self::RtpobserverRemoveProducer, - ]; - } - - impl ::core::convert::TryFrom for Method { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(Method::WorkerClose), - 1 => ::core::result::Result::Ok(Method::WorkerDump), - 2 => ::core::result::Result::Ok(Method::WorkerGetResourceUsage), - 3 => ::core::result::Result::Ok(Method::WorkerUpdateSettings), - 4 => ::core::result::Result::Ok(Method::WorkerCreateWebrtcserver), - 5 => ::core::result::Result::Ok(Method::WorkerCreateRouter), - 6 => ::core::result::Result::Ok(Method::WorkerWebrtcserverClose), - 7 => ::core::result::Result::Ok(Method::WorkerCloseRouter), - 8 => ::core::result::Result::Ok(Method::WebrtcserverDump), - 9 => ::core::result::Result::Ok(Method::RouterDump), - 10 => ::core::result::Result::Ok(Method::RouterCreateWebrtctransport), - 11 => ::core::result::Result::Ok( - Method::RouterCreateWebrtctransportWithServer, - ), - 12 => ::core::result::Result::Ok(Method::RouterCreatePlaintransport), - 13 => ::core::result::Result::Ok(Method::RouterCreatePipetransport), - 14 => ::core::result::Result::Ok(Method::RouterCreateDirecttransport), - 15 => ::core::result::Result::Ok(Method::RouterCloseTransport), - 16 => ::core::result::Result::Ok(Method::RouterCreateActivespeakerobserver), - 17 => ::core::result::Result::Ok(Method::RouterCreateAudiolevelobserver), - 18 => ::core::result::Result::Ok(Method::RouterCloseRtpobserver), - 19 => ::core::result::Result::Ok(Method::TransportDump), - 20 => ::core::result::Result::Ok(Method::TransportGetStats), - 21 => ::core::result::Result::Ok(Method::TransportConnect), - 22 => ::core::result::Result::Ok(Method::TransportSetMaxIncomingBitrate), - 23 => ::core::result::Result::Ok(Method::TransportSetMaxOutgoingBitrate), - 24 => ::core::result::Result::Ok(Method::TransportSetMinOutgoingBitrate), - 25 => ::core::result::Result::Ok(Method::TransportRestartIce), - 26 => ::core::result::Result::Ok(Method::TransportProduce), - 27 => ::core::result::Result::Ok(Method::TransportProduceData), - 28 => ::core::result::Result::Ok(Method::TransportConsume), - 29 => ::core::result::Result::Ok(Method::TransportConsumeData), - 30 => ::core::result::Result::Ok(Method::TransportEnableTraceEvent), - 31 => ::core::result::Result::Ok(Method::TransportCloseProducer), - 32 => ::core::result::Result::Ok(Method::TransportCloseConsumer), - 33 => ::core::result::Result::Ok(Method::TransportCloseDataproducer), - 34 => ::core::result::Result::Ok(Method::TransportCloseDataconsumer), - 35 => ::core::result::Result::Ok(Method::PlaintransportConnect), - 36 => ::core::result::Result::Ok(Method::PipetransportConnect), - 37 => ::core::result::Result::Ok(Method::WebrtctransportConnect), - 38 => ::core::result::Result::Ok(Method::ProducerDump), - 39 => ::core::result::Result::Ok(Method::ProducerGetStats), - 40 => ::core::result::Result::Ok(Method::ProducerPause), - 41 => ::core::result::Result::Ok(Method::ProducerResume), - 42 => ::core::result::Result::Ok(Method::ProducerEnableTraceEvent), - 43 => ::core::result::Result::Ok(Method::ConsumerDump), - 44 => ::core::result::Result::Ok(Method::ConsumerGetStats), - 45 => ::core::result::Result::Ok(Method::ConsumerPause), - 46 => ::core::result::Result::Ok(Method::ConsumerResume), - 47 => ::core::result::Result::Ok(Method::ConsumerSetPreferredLayers), - 48 => ::core::result::Result::Ok(Method::ConsumerSetPriority), - 49 => ::core::result::Result::Ok(Method::ConsumerRequestKeyFrame), - 50 => ::core::result::Result::Ok(Method::ConsumerEnableTraceEvent), - 51 => ::core::result::Result::Ok(Method::DataproducerDump), - 52 => ::core::result::Result::Ok(Method::DataproducerGetStats), - 53 => ::core::result::Result::Ok(Method::DataproducerPause), - 54 => ::core::result::Result::Ok(Method::DataproducerResume), - 55 => ::core::result::Result::Ok(Method::DataconsumerDump), - 56 => ::core::result::Result::Ok(Method::DataconsumerGetStats), - 57 => ::core::result::Result::Ok(Method::DataconsumerPause), - 58 => ::core::result::Result::Ok(Method::DataconsumerResume), - 59 => ::core::result::Result::Ok(Method::DataconsumerGetBufferedAmount), - 60 => ::core::result::Result::Ok( - Method::DataconsumerSetBufferedAmountLowThreshold, - ), - 61 => ::core::result::Result::Ok(Method::DataconsumerSend), - 62 => ::core::result::Result::Ok(Method::DataconsumerSetSubchannels), - 63 => ::core::result::Result::Ok(Method::RtpobserverPause), - 64 => ::core::result::Result::Ok(Method::RtpobserverResume), - 65 => ::core::result::Result::Ok(Method::RtpobserverAddProducer), - 66 => ::core::result::Result::Ok(Method::RtpobserverRemoveProducer), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: Method) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for Method { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for Method { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for Method { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Method { - *self - } - } - - impl ::planus::WriteAsDefault for Method { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &Method, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for Method { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for Method { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for Method { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "Method", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for Method { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The union `Body` in the namespace `FBS.Request` - /// - /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/request.fbs:81` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub enum Body { - /// The variant `Worker_UpdateSettingsRequest` in the union `Body` - WorkerUpdateSettingsRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Worker_CreateWebRtcServerRequest` in the union `Body` - WorkerCreateWebRtcServerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Worker_CloseWebRtcServerRequest` in the union `Body` - WorkerCloseWebRtcServerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Worker_CreateRouterRequest` in the union `Body` - WorkerCreateRouterRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Worker_CloseRouterRequest` in the union `Body` - WorkerCloseRouterRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CreateWebRtcTransportRequest` in the union `Body` - RouterCreateWebRtcTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CreatePlainTransportRequest` in the union `Body` - RouterCreatePlainTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CreatePipeTransportRequest` in the union `Body` - RouterCreatePipeTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CreateDirectTransportRequest` in the union `Body` - RouterCreateDirectTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CreateActiveSpeakerObserverRequest` in the union `Body` - RouterCreateActiveSpeakerObserverRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CreateAudioLevelObserverRequest` in the union `Body` - RouterCreateAudioLevelObserverRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CloseTransportRequest` in the union `Body` - RouterCloseTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_CloseRtpObserverRequest` in the union `Body` - RouterCloseRtpObserverRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_SetMaxIncomingBitrateRequest` in the union `Body` - TransportSetMaxIncomingBitrateRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_SetMaxOutgoingBitrateRequest` in the union `Body` - TransportSetMaxOutgoingBitrateRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_SetMinOutgoingBitrateRequest` in the union `Body` - TransportSetMinOutgoingBitrateRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_ProduceRequest` in the union `Body` - TransportProduceRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_ConsumeRequest` in the union `Body` - TransportConsumeRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_ProduceDataRequest` in the union `Body` - TransportProduceDataRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_ConsumeDataRequest` in the union `Body` - TransportConsumeDataRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_EnableTraceEventRequest` in the union `Body` - TransportEnableTraceEventRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_CloseProducerRequest` in the union `Body` - TransportCloseProducerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_CloseConsumerRequest` in the union `Body` - TransportCloseConsumerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_CloseDataProducerRequest` in the union `Body` - TransportCloseDataProducerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_CloseDataConsumerRequest` in the union `Body` - TransportCloseDataConsumerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PlainTransport_ConnectRequest` in the union `Body` - PlainTransportConnectRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PipeTransport_ConnectRequest` in the union `Body` - PipeTransportConnectRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `WebRtcTransport_ConnectRequest` in the union `Body` - WebRtcTransportConnectRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Producer_EnableTraceEventRequest` in the union `Body` - ProducerEnableTraceEventRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_SetPreferredLayersRequest` in the union `Body` - ConsumerSetPreferredLayersRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_SetPriorityRequest` in the union `Body` - ConsumerSetPriorityRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_EnableTraceEventRequest` in the union `Body` - ConsumerEnableTraceEventRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_SetBufferedAmountLowThresholdRequest` in the union `Body` - DataConsumerSetBufferedAmountLowThresholdRequest( - ::planus::alloc::boxed::Box< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - ), - - /// The variant `DataConsumer_SendRequest` in the union `Body` - DataConsumerSendRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_SetSubchannelsRequest` in the union `Body` - DataConsumerSetSubchannelsRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `RtpObserver_AddProducerRequest` in the union `Body` - RtpObserverAddProducerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant `RtpObserver_RemoveProducerRequest` in the union `Body` - RtpObserverRemoveProducerRequest( - ::planus::alloc::boxed::Box, - ), - } - - impl Body { - /// Creates a [BodyBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BodyBuilder<::planus::Uninitialized> { - BodyBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_worker_update_settings_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_worker_create_web_rtc_server_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_worker_close_web_rtc_server_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_worker_create_router_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_worker_close_router_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_create_web_rtc_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_create_plain_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_create_pipe_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_create_direct_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_create_active_speaker_observer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::router::CreateActiveSpeakerObserverRequest, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_create_audio_level_observer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_close_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_close_rtp_observer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_set_max_incoming_bitrate_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_set_max_outgoing_bitrate_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_set_min_outgoing_bitrate_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_produce_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_consume_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_produce_data_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_consume_data_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_enable_trace_event_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_close_producer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_close_consumer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_close_data_producer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_close_data_consumer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_plain_transport_connect_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pipe_transport_connect_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_connect_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_enable_trace_event_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_set_preferred_layers_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_set_priority_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_enable_trace_event_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_set_buffered_amount_low_threshold_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_send_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_set_subchannels_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(35, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtp_observer_add_producer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(36, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtp_observer_remove_producer_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(37, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for Body { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::WorkerUpdateSettingsRequest(value) => { - Self::create_worker_update_settings_request(builder, value) - } - Self::WorkerCreateWebRtcServerRequest(value) => { - Self::create_worker_create_web_rtc_server_request(builder, value) - } - Self::WorkerCloseWebRtcServerRequest(value) => { - Self::create_worker_close_web_rtc_server_request(builder, value) - } - Self::WorkerCreateRouterRequest(value) => { - Self::create_worker_create_router_request(builder, value) - } - Self::WorkerCloseRouterRequest(value) => { - Self::create_worker_close_router_request(builder, value) - } - Self::RouterCreateWebRtcTransportRequest(value) => { - Self::create_router_create_web_rtc_transport_request(builder, value) - } - Self::RouterCreatePlainTransportRequest(value) => { - Self::create_router_create_plain_transport_request(builder, value) - } - Self::RouterCreatePipeTransportRequest(value) => { - Self::create_router_create_pipe_transport_request(builder, value) - } - Self::RouterCreateDirectTransportRequest(value) => { - Self::create_router_create_direct_transport_request(builder, value) - } - Self::RouterCreateActiveSpeakerObserverRequest(value) => { - Self::create_router_create_active_speaker_observer_request( - builder, value, - ) - } - Self::RouterCreateAudioLevelObserverRequest(value) => { - Self::create_router_create_audio_level_observer_request(builder, value) - } - Self::RouterCloseTransportRequest(value) => { - Self::create_router_close_transport_request(builder, value) - } - Self::RouterCloseRtpObserverRequest(value) => { - Self::create_router_close_rtp_observer_request(builder, value) - } - Self::TransportSetMaxIncomingBitrateRequest(value) => { - Self::create_transport_set_max_incoming_bitrate_request(builder, value) - } - Self::TransportSetMaxOutgoingBitrateRequest(value) => { - Self::create_transport_set_max_outgoing_bitrate_request(builder, value) - } - Self::TransportSetMinOutgoingBitrateRequest(value) => { - Self::create_transport_set_min_outgoing_bitrate_request(builder, value) - } - Self::TransportProduceRequest(value) => { - Self::create_transport_produce_request(builder, value) - } - Self::TransportConsumeRequest(value) => { - Self::create_transport_consume_request(builder, value) - } - Self::TransportProduceDataRequest(value) => { - Self::create_transport_produce_data_request(builder, value) - } - Self::TransportConsumeDataRequest(value) => { - Self::create_transport_consume_data_request(builder, value) - } - Self::TransportEnableTraceEventRequest(value) => { - Self::create_transport_enable_trace_event_request(builder, value) - } - Self::TransportCloseProducerRequest(value) => { - Self::create_transport_close_producer_request(builder, value) - } - Self::TransportCloseConsumerRequest(value) => { - Self::create_transport_close_consumer_request(builder, value) - } - Self::TransportCloseDataProducerRequest(value) => { - Self::create_transport_close_data_producer_request(builder, value) - } - Self::TransportCloseDataConsumerRequest(value) => { - Self::create_transport_close_data_consumer_request(builder, value) - } - Self::PlainTransportConnectRequest(value) => { - Self::create_plain_transport_connect_request(builder, value) - } - Self::PipeTransportConnectRequest(value) => { - Self::create_pipe_transport_connect_request(builder, value) - } - Self::WebRtcTransportConnectRequest(value) => { - Self::create_web_rtc_transport_connect_request(builder, value) - } - Self::ProducerEnableTraceEventRequest(value) => { - Self::create_producer_enable_trace_event_request(builder, value) - } - Self::ConsumerSetPreferredLayersRequest(value) => { - Self::create_consumer_set_preferred_layers_request(builder, value) - } - Self::ConsumerSetPriorityRequest(value) => { - Self::create_consumer_set_priority_request(builder, value) - } - Self::ConsumerEnableTraceEventRequest(value) => { - Self::create_consumer_enable_trace_event_request(builder, value) - } - Self::DataConsumerSetBufferedAmountLowThresholdRequest(value) => { - Self::create_data_consumer_set_buffered_amount_low_threshold_request( - builder, value, - ) - } - Self::DataConsumerSendRequest(value) => { - Self::create_data_consumer_send_request(builder, value) - } - Self::DataConsumerSetSubchannelsRequest(value) => { - Self::create_data_consumer_set_subchannels_request(builder, value) - } - Self::RtpObserverAddProducerRequest(value) => { - Self::create_rtp_observer_add_producer_request(builder, value) - } - Self::RtpObserverRemoveProducerRequest(value) => { - Self::create_rtp_observer_remove_producer_request(builder, value) - } - } - } - } - - impl ::planus::WriteAsOptionalUnion for Body { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [Body] type. - /// - /// Can be created using the [Body::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BodyBuilder(T); - - impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`Worker_UpdateSettingsRequest` variant](Body#variant.WorkerUpdateSettingsRequest). - #[inline] - pub fn worker_update_settings_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Worker_CreateWebRtcServerRequest` variant](Body#variant.WorkerCreateWebRtcServerRequest). - #[inline] - pub fn worker_create_web_rtc_server_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Worker_CloseWebRtcServerRequest` variant](Body#variant.WorkerCloseWebRtcServerRequest). - #[inline] - pub fn worker_close_web_rtc_server_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Worker_CreateRouterRequest` variant](Body#variant.WorkerCreateRouterRequest). - #[inline] - pub fn worker_create_router_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Worker_CloseRouterRequest` variant](Body#variant.WorkerCloseRouterRequest). - #[inline] - pub fn worker_close_router_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CreateWebRtcTransportRequest` variant](Body#variant.RouterCreateWebRtcTransportRequest). - #[inline] - pub fn router_create_web_rtc_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CreatePlainTransportRequest` variant](Body#variant.RouterCreatePlainTransportRequest). - #[inline] - pub fn router_create_plain_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CreatePipeTransportRequest` variant](Body#variant.RouterCreatePipeTransportRequest). - #[inline] - pub fn router_create_pipe_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CreateDirectTransportRequest` variant](Body#variant.RouterCreateDirectTransportRequest). - #[inline] - pub fn router_create_direct_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CreateActiveSpeakerObserverRequest` variant](Body#variant.RouterCreateActiveSpeakerObserverRequest). - #[inline] - pub fn router_create_active_speaker_observer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CreateAudioLevelObserverRequest` variant](Body#variant.RouterCreateAudioLevelObserverRequest). - #[inline] - pub fn router_create_audio_level_observer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CloseTransportRequest` variant](Body#variant.RouterCloseTransportRequest). - #[inline] - pub fn router_close_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_CloseRtpObserverRequest` variant](Body#variant.RouterCloseRtpObserverRequest). - #[inline] - pub fn router_close_rtp_observer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_SetMaxIncomingBitrateRequest` variant](Body#variant.TransportSetMaxIncomingBitrateRequest). - #[inline] - pub fn transport_set_max_incoming_bitrate_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_SetMaxOutgoingBitrateRequest` variant](Body#variant.TransportSetMaxOutgoingBitrateRequest). - #[inline] - pub fn transport_set_max_outgoing_bitrate_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_SetMinOutgoingBitrateRequest` variant](Body#variant.TransportSetMinOutgoingBitrateRequest). - #[inline] - pub fn transport_set_min_outgoing_bitrate_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_ProduceRequest` variant](Body#variant.TransportProduceRequest). - #[inline] - pub fn transport_produce_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_ConsumeRequest` variant](Body#variant.TransportConsumeRequest). - #[inline] - pub fn transport_consume_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_ProduceDataRequest` variant](Body#variant.TransportProduceDataRequest). - #[inline] - pub fn transport_produce_data_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_ConsumeDataRequest` variant](Body#variant.TransportConsumeDataRequest). - #[inline] - pub fn transport_consume_data_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_EnableTraceEventRequest` variant](Body#variant.TransportEnableTraceEventRequest). - #[inline] - pub fn transport_enable_trace_event_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_CloseProducerRequest` variant](Body#variant.TransportCloseProducerRequest). - #[inline] - pub fn transport_close_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_CloseConsumerRequest` variant](Body#variant.TransportCloseConsumerRequest). - #[inline] - pub fn transport_close_consumer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_CloseDataProducerRequest` variant](Body#variant.TransportCloseDataProducerRequest). - #[inline] - pub fn transport_close_data_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_CloseDataConsumerRequest` variant](Body#variant.TransportCloseDataConsumerRequest). - #[inline] - pub fn transport_close_data_consumer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PlainTransport_ConnectRequest` variant](Body#variant.PlainTransportConnectRequest). - #[inline] - pub fn plain_transport_connect_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PipeTransport_ConnectRequest` variant](Body#variant.PipeTransportConnectRequest). - #[inline] - pub fn pipe_transport_connect_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_ConnectRequest` variant](Body#variant.WebRtcTransportConnectRequest). - #[inline] - pub fn web_rtc_transport_connect_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_EnableTraceEventRequest` variant](Body#variant.ProducerEnableTraceEventRequest). - #[inline] - pub fn producer_enable_trace_event_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_SetPreferredLayersRequest` variant](Body#variant.ConsumerSetPreferredLayersRequest). - #[inline] - pub fn consumer_set_preferred_layers_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_SetPriorityRequest` variant](Body#variant.ConsumerSetPriorityRequest). - #[inline] - pub fn consumer_set_priority_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<31, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_EnableTraceEventRequest` variant](Body#variant.ConsumerEnableTraceEventRequest). - #[inline] - pub fn consumer_enable_trace_event_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<32, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_SetBufferedAmountLowThresholdRequest` variant](Body#variant.DataConsumerSetBufferedAmountLowThresholdRequest). - #[inline] - pub fn data_consumer_set_buffered_amount_low_threshold_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<33, T>> - where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_SendRequest` variant](Body#variant.DataConsumerSendRequest). - #[inline] - pub fn data_consumer_send_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<34, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_SetSubchannelsRequest` variant](Body#variant.DataConsumerSetSubchannelsRequest). - #[inline] - pub fn data_consumer_set_subchannels_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<35, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtpObserver_AddProducerRequest` variant](Body#variant.RtpObserverAddProducerRequest). - #[inline] - pub fn rtp_observer_add_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<36, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtpObserver_RemoveProducerRequest` variant](Body#variant.RtpObserverRemoveProducerRequest). - #[inline] - pub fn rtp_observer_remove_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<37, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - } - - impl BodyBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<31, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<31, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<32, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<32, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<33, T>> - where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<33, T>> - where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<34, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(34, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<34, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<35, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(35, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<35, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<36, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(36, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<36, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<37, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(37, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<37, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - WorkerUpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), - WorkerCreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), - WorkerCloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), - WorkerCreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), - WorkerCloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), - RouterCreateWebRtcTransportRequest( - super::router::CreateWebRtcTransportRequestRef<'a>, - ), - RouterCreatePlainTransportRequest( - super::router::CreatePlainTransportRequestRef<'a>, - ), - RouterCreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), - RouterCreateDirectTransportRequest( - super::router::CreateDirectTransportRequestRef<'a>, - ), - RouterCreateActiveSpeakerObserverRequest( - super::router::CreateActiveSpeakerObserverRequestRef<'a>, - ), - RouterCreateAudioLevelObserverRequest( - super::router::CreateAudioLevelObserverRequestRef<'a>, - ), - RouterCloseTransportRequest(super::router::CloseTransportRequestRef<'a>), - RouterCloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), - TransportSetMaxIncomingBitrateRequest( - super::transport::SetMaxIncomingBitrateRequestRef<'a>, - ), - TransportSetMaxOutgoingBitrateRequest( - super::transport::SetMaxOutgoingBitrateRequestRef<'a>, - ), - TransportSetMinOutgoingBitrateRequest( - super::transport::SetMinOutgoingBitrateRequestRef<'a>, - ), - TransportProduceRequest(super::transport::ProduceRequestRef<'a>), - TransportConsumeRequest(super::transport::ConsumeRequestRef<'a>), - TransportProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), - TransportConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), - TransportEnableTraceEventRequest(super::transport::EnableTraceEventRequestRef<'a>), - TransportCloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), - TransportCloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), - TransportCloseDataProducerRequest( - super::transport::CloseDataProducerRequestRef<'a>, - ), - TransportCloseDataConsumerRequest( - super::transport::CloseDataConsumerRequestRef<'a>, - ), - PlainTransportConnectRequest(super::plain_transport::ConnectRequestRef<'a>), - PipeTransportConnectRequest(super::pipe_transport::ConnectRequestRef<'a>), - WebRtcTransportConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), - ProducerEnableTraceEventRequest(super::producer::EnableTraceEventRequestRef<'a>), - ConsumerSetPreferredLayersRequest( - super::consumer::SetPreferredLayersRequestRef<'a>, - ), - ConsumerSetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), - ConsumerEnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), - DataConsumerSetBufferedAmountLowThresholdRequest( - super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, - ), - DataConsumerSendRequest(super::data_consumer::SendRequestRef<'a>), - DataConsumerSetSubchannelsRequest( - super::data_consumer::SetSubchannelsRequestRef<'a>, - ), - RtpObserverAddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), - RtpObserverRemoveProducerRequest(super::rtp_observer::RemoveProducerRequestRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; - - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::WorkerUpdateSettingsRequest(value) => { - Self::WorkerUpdateSettingsRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WorkerCreateWebRtcServerRequest(value) => { - Self::WorkerCreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WorkerCloseWebRtcServerRequest(value) => { - Self::WorkerCloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WorkerCreateRouterRequest(value) => { - Self::WorkerCreateRouterRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WorkerCloseRouterRequest(value) => { - Self::WorkerCloseRouterRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::RouterCreateWebRtcTransportRequest(value) => { - Self::RouterCreateWebRtcTransportRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RouterCreatePlainTransportRequest(value) => { - Self::RouterCreatePlainTransportRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RouterCreatePipeTransportRequest(value) => { - Self::RouterCreatePipeTransportRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RouterCreateDirectTransportRequest(value) => { - Self::RouterCreateDirectTransportRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RouterCreateActiveSpeakerObserverRequest(value) => { - Self::RouterCreateActiveSpeakerObserverRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RouterCreateAudioLevelObserverRequest(value) => { - Self::RouterCreateAudioLevelObserverRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RouterCloseTransportRequest(value) => { - Self::RouterCloseTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::RouterCloseRtpObserverRequest(value) => { - Self::RouterCloseRtpObserverRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportSetMaxIncomingBitrateRequest(value) => { - Self::TransportSetMaxIncomingBitrateRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::TransportSetMaxOutgoingBitrateRequest(value) => { - Self::TransportSetMaxOutgoingBitrateRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::TransportSetMinOutgoingBitrateRequest(value) => { - Self::TransportSetMinOutgoingBitrateRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::TransportProduceRequest(value) => { - Self::TransportProduceRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportConsumeRequest(value) => { - Self::TransportConsumeRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportProduceDataRequest(value) => { - Self::TransportProduceDataRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportConsumeDataRequest(value) => { - Self::TransportConsumeDataRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportEnableTraceEventRequest(value) => { - Self::TransportEnableTraceEventRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::TransportCloseProducerRequest(value) => { - Self::TransportCloseProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportCloseConsumerRequest(value) => { - Self::TransportCloseConsumerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportCloseDataProducerRequest(value) => { - Self::TransportCloseDataProducerRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::TransportCloseDataConsumerRequest(value) => { - Self::TransportCloseDataConsumerRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::PlainTransportConnectRequest(value) => { - Self::PlainTransportConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PipeTransportConnectRequest(value) => { - Self::PipeTransportConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WebRtcTransportConnectRequest(value) => { - Self::WebRtcTransportConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ProducerEnableTraceEventRequest(value) => { - Self::ProducerEnableTraceEventRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerSetPreferredLayersRequest(value) => { - Self::ConsumerSetPreferredLayersRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::ConsumerSetPriorityRequest(value) => { - Self::ConsumerSetPriorityRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerEnableTraceEventRequest(value) => { - Self::ConsumerEnableTraceEventRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerSetBufferedAmountLowThresholdRequest(value) => { - Self::DataConsumerSetBufferedAmountLowThresholdRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::DataConsumerSendRequest(value) => { - Self::DataConsumerSendRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerSetSubchannelsRequest(value) => { - Self::DataConsumerSetSubchannelsRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::RtpObserverAddProducerRequest(value) => { - Self::RtpObserverAddProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::RtpObserverRemoveProducerRequest(value) => { - Self::RtpObserverRemoveProducerRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for BodyRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::WorkerUpdateSettingsRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::WorkerCreateWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::WorkerCloseWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::WorkerCreateRouterRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::WorkerCloseRouterRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok(Self::RouterCreateWebRtcTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 7 => ::core::result::Result::Ok(Self::RouterCreatePlainTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 8 => ::core::result::Result::Ok(Self::RouterCreatePipeTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 9 => ::core::result::Result::Ok(Self::RouterCreateDirectTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 10 => ::core::result::Result::Ok( - Self::RouterCreateActiveSpeakerObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 11 => { - ::core::result::Result::Ok(Self::RouterCreateAudioLevelObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 12 => ::core::result::Result::Ok(Self::RouterCloseTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 13 => ::core::result::Result::Ok(Self::RouterCloseRtpObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => { - ::core::result::Result::Ok(Self::TransportSetMaxIncomingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 15 => { - ::core::result::Result::Ok(Self::TransportSetMaxOutgoingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 16 => { - ::core::result::Result::Ok(Self::TransportSetMinOutgoingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 17 => ::core::result::Result::Ok(Self::TransportProduceRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 18 => ::core::result::Result::Ok(Self::TransportConsumeRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 19 => ::core::result::Result::Ok(Self::TransportProduceDataRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 20 => ::core::result::Result::Ok(Self::TransportConsumeDataRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 21 => ::core::result::Result::Ok(Self::TransportEnableTraceEventRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 22 => ::core::result::Result::Ok(Self::TransportCloseProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 23 => ::core::result::Result::Ok(Self::TransportCloseConsumerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 24 => ::core::result::Result::Ok(Self::TransportCloseDataProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 25 => ::core::result::Result::Ok(Self::TransportCloseDataConsumerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 26 => ::core::result::Result::Ok(Self::PlainTransportConnectRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 27 => ::core::result::Result::Ok(Self::PipeTransportConnectRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 28 => ::core::result::Result::Ok(Self::WebRtcTransportConnectRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 29 => ::core::result::Result::Ok(Self::ProducerEnableTraceEventRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 30 => ::core::result::Result::Ok(Self::ConsumerSetPreferredLayersRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 31 => ::core::result::Result::Ok(Self::ConsumerSetPriorityRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 32 => ::core::result::Result::Ok(Self::ConsumerEnableTraceEventRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 33 => ::core::result::Result::Ok( - Self::DataConsumerSetBufferedAmountLowThresholdRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 34 => ::core::result::Result::Ok(Self::DataConsumerSendRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 35 => ::core::result::Result::Ok(Self::DataConsumerSetSubchannelsRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 36 => ::core::result::Result::Ok(Self::RtpObserverAddProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 37 => ::core::result::Result::Ok(Self::RtpObserverRemoveProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `Request` in the namespace `FBS.Request` - /// - /// Generated from these locations: - /// * Table `Request` in the file `../worker/fbs/request.fbs:121` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Request { - /// The field `id` in the table `Request` - pub id: u32, - /// The field `method` in the table `Request` - pub method: self::Method, - /// The field `handler_id` in the table `Request` - pub handler_id: ::planus::alloc::string::String, - /// The field `body` in the table `Request` - pub body: ::core::option::Option, - } - - impl Request { - /// Creates a [RequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RequestBuilder<()> { - RequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAsDefault, - field_method: impl ::planus::WriteAsDefault, - field_handler_id: impl ::planus::WriteAs<::planus::Offset>, - field_body: impl ::planus::WriteAsOptionalUnion, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder, &0); - let prepared_method = field_method.prepare(builder, &self::Method::WorkerClose); - let prepared_handler_id = field_handler_id.prepare(builder); - let prepared_body = field_body.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - if prepared_id.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset>(2); - if prepared_body.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_method.is_some() { - table_writer.write_entry::(1); - } - if prepared_body.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_id) = prepared_id { - object_writer.write::<_, _, 4>(&prepared_id); - } - object_writer.write::<_, _, 4>(&prepared_handler_id); - if let ::core::option::Option::Some(prepared_body) = prepared_body { - object_writer.write::<_, _, 4>(&prepared_body.offset()); - } - if let ::core::option::Option::Some(prepared_method) = prepared_method { - object_writer.write::<_, _, 1>(&prepared_method); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - object_writer.write::<_, _, 1>(&prepared_body.tag()); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Request { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Request { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Request { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Request::create(builder, self.id, self.method, &self.handler_id, &self.body) - } - } - - /// Builder for serializing an instance of the [Request] type. - /// - /// Can be created using the [Request::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RequestBuilder(State); - - impl RequestBuilder<()> { - /// Setter for the [`id` field](Request#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> RequestBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - RequestBuilder((value,)) - } - - /// Sets the [`id` field](Request#structfield.id) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn id_as_default(self) -> RequestBuilder<(::planus::DefaultValue,)> { - self.id(::planus::DefaultValue) - } - } - - impl RequestBuilder<(T0,)> { - /// Setter for the [`method` field](Request#structfield.method). - #[inline] - #[allow(clippy::type_complexity)] - pub fn method(self, value: T1) -> RequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RequestBuilder((v0, value)) - } - - /// Sets the [`method` field](Request#structfield.method) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn method_as_default(self) -> RequestBuilder<(T0, ::planus::DefaultValue)> { - self.method(::planus::DefaultValue) - } - } - - impl RequestBuilder<(T0, T1)> { - /// Setter for the [`handler_id` field](Request#structfield.handler_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn handler_id(self, value: T2) -> RequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - RequestBuilder((v0, v1, value)) - } - } - - impl RequestBuilder<(T0, T1, T2)> { - /// Setter for the [`body` field](Request#structfield.body). - #[inline] - #[allow(clippy::type_complexity)] - pub fn body(self, value: T3) -> RequestBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptionalUnion, - { - let (v0, v1, v2) = self.0; - RequestBuilder((v0, v1, v2, value)) - } - - /// Sets the [`body` field](Request#structfield.body) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn body_as_null(self) -> RequestBuilder<(T0, T1, T2, ())> { - self.body(()) - } - } - - impl RequestBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Request]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAs<::planus::Offset> - for RequestBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for RequestBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOffset for RequestBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - Request::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [Request]. - #[derive(Copy, Clone)] - pub struct RequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RequestRef<'a> { - /// Getter for the [`id` field](Request#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Request", "id")?.unwrap_or(0)) - } - - /// Getter for the [`method` field](Request#structfield.method). - #[inline] - pub fn method(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "Request", "method")? - .unwrap_or(self::Method::WorkerClose), - ) - } - - /// Getter for the [`handler_id` field](Request#structfield.handler_id). - #[inline] - pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "Request", "handler_id") - } - - /// Getter for the [`body` field](Request#structfield.body). - #[inline] - pub fn body(&self) -> ::planus::Result<::core::option::Option>> { - self.0.access_union(3, "Request", "body") - } - } - - impl<'a> ::core::fmt::Debug for RequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RequestRef"); - f.field("id", &self.id()); - f.field("method", &self.method()); - f.field("handler_id", &self.handler_id()); - if let ::core::option::Option::Some(field_body) = self.body().transpose() { - f.field("body", &field_body); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Request { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - method: ::core::convert::TryInto::try_into(value.method()?)?, - handler_id: ::core::convert::TryInto::try_into(value.handler_id()?)?, - body: if let ::core::option::Option::Some(body) = value.body()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(body)?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Request { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RequestRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Response` - /// - /// Generated from these locations: - /// * File `../worker/fbs/response.fbs` - pub mod response { - /// The union `Body` in the namespace `FBS.Response` - /// - /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/response.fbs:12` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub enum Body { - /// The variant `Worker_DumpResponse` in the union `Body` - WorkerDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `Worker_ResourceUsageResponse` in the union `Body` - WorkerResourceUsageResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `WebRtcServer_DumpResponse` in the union `Body` - WebRtcServerDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Router_DumpResponse` in the union `Body` - RouterDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `Transport_ProduceResponse` in the union `Body` - TransportProduceResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_ConsumeResponse` in the union `Body` - TransportConsumeResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Transport_RestartIceResponse` in the union `Body` - TransportRestartIceResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PlainTransport_ConnectResponse` in the union `Body` - PlainTransportConnectResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PlainTransport_DumpResponse` in the union `Body` - PlainTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PlainTransport_GetStatsResponse` in the union `Body` - PlainTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PipeTransport_ConnectResponse` in the union `Body` - PipeTransportConnectResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PipeTransport_DumpResponse` in the union `Body` - PipeTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `PipeTransport_GetStatsResponse` in the union `Body` - PipeTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DirectTransport_DumpResponse` in the union `Body` - DirectTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DirectTransport_GetStatsResponse` in the union `Body` - DirectTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `WebRtcTransport_ConnectResponse` in the union `Body` - WebRtcTransportConnectResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `WebRtcTransport_DumpResponse` in the union `Body` - WebRtcTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `WebRtcTransport_GetStatsResponse` in the union `Body` - WebRtcTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Producer_DumpResponse` in the union `Body` - ProducerDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `Producer_GetStatsResponse` in the union `Body` - ProducerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_DumpResponse` in the union `Body` - ConsumerDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `Consumer_GetStatsResponse` in the union `Body` - ConsumerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_SetPreferredLayersResponse` in the union `Body` - ConsumerSetPreferredLayersResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `Consumer_SetPriorityResponse` in the union `Body` - ConsumerSetPriorityResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataProducer_DumpResponse` in the union `Body` - DataProducerDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataProducer_GetStatsResponse` in the union `Body` - DataProducerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_GetBufferedAmountResponse` in the union `Body` - DataConsumerGetBufferedAmountResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_DumpResponse` in the union `Body` - DataConsumerDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_GetStatsResponse` in the union `Body` - DataConsumerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `DataConsumer_SetSubchannelsResponse` in the union `Body` - DataConsumerSetSubchannelsResponse( - ::planus::alloc::boxed::Box, - ), - } - - impl Body { - /// Creates a [BodyBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BodyBuilder<::planus::Uninitialized> { - BodyBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_worker_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_worker_resource_usage_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_server_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_router_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_produce_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_consume_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_transport_restart_ice_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_plain_transport_connect_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_plain_transport_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_plain_transport_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pipe_transport_connect_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pipe_transport_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pipe_transport_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_direct_transport_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_direct_transport_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_connect_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_web_rtc_transport_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_producer_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_set_preferred_layers_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_consumer_set_priority_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_producer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_producer_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_get_buffered_amount_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_data_consumer_set_subchannels_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for Body { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::WorkerDumpResponse(value) => { - Self::create_worker_dump_response(builder, value) - } - Self::WorkerResourceUsageResponse(value) => { - Self::create_worker_resource_usage_response(builder, value) - } - Self::WebRtcServerDumpResponse(value) => { - Self::create_web_rtc_server_dump_response(builder, value) - } - Self::RouterDumpResponse(value) => { - Self::create_router_dump_response(builder, value) - } - Self::TransportProduceResponse(value) => { - Self::create_transport_produce_response(builder, value) - } - Self::TransportConsumeResponse(value) => { - Self::create_transport_consume_response(builder, value) - } - Self::TransportRestartIceResponse(value) => { - Self::create_transport_restart_ice_response(builder, value) - } - Self::PlainTransportConnectResponse(value) => { - Self::create_plain_transport_connect_response(builder, value) - } - Self::PlainTransportDumpResponse(value) => { - Self::create_plain_transport_dump_response(builder, value) - } - Self::PlainTransportGetStatsResponse(value) => { - Self::create_plain_transport_get_stats_response(builder, value) - } - Self::PipeTransportConnectResponse(value) => { - Self::create_pipe_transport_connect_response(builder, value) - } - Self::PipeTransportDumpResponse(value) => { - Self::create_pipe_transport_dump_response(builder, value) - } - Self::PipeTransportGetStatsResponse(value) => { - Self::create_pipe_transport_get_stats_response(builder, value) - } - Self::DirectTransportDumpResponse(value) => { - Self::create_direct_transport_dump_response(builder, value) - } - Self::DirectTransportGetStatsResponse(value) => { - Self::create_direct_transport_get_stats_response(builder, value) - } - Self::WebRtcTransportConnectResponse(value) => { - Self::create_web_rtc_transport_connect_response(builder, value) - } - Self::WebRtcTransportDumpResponse(value) => { - Self::create_web_rtc_transport_dump_response(builder, value) - } - Self::WebRtcTransportGetStatsResponse(value) => { - Self::create_web_rtc_transport_get_stats_response(builder, value) - } - Self::ProducerDumpResponse(value) => { - Self::create_producer_dump_response(builder, value) - } - Self::ProducerGetStatsResponse(value) => { - Self::create_producer_get_stats_response(builder, value) - } - Self::ConsumerDumpResponse(value) => { - Self::create_consumer_dump_response(builder, value) - } - Self::ConsumerGetStatsResponse(value) => { - Self::create_consumer_get_stats_response(builder, value) - } - Self::ConsumerSetPreferredLayersResponse(value) => { - Self::create_consumer_set_preferred_layers_response(builder, value) - } - Self::ConsumerSetPriorityResponse(value) => { - Self::create_consumer_set_priority_response(builder, value) - } - Self::DataProducerDumpResponse(value) => { - Self::create_data_producer_dump_response(builder, value) - } - Self::DataProducerGetStatsResponse(value) => { - Self::create_data_producer_get_stats_response(builder, value) - } - Self::DataConsumerGetBufferedAmountResponse(value) => { - Self::create_data_consumer_get_buffered_amount_response(builder, value) - } - Self::DataConsumerDumpResponse(value) => { - Self::create_data_consumer_dump_response(builder, value) - } - Self::DataConsumerGetStatsResponse(value) => { - Self::create_data_consumer_get_stats_response(builder, value) - } - Self::DataConsumerSetSubchannelsResponse(value) => { - Self::create_data_consumer_set_subchannels_response(builder, value) - } - } - } - } - - impl ::planus::WriteAsOptionalUnion for Body { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [Body] type. - /// - /// Can be created using the [Body::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BodyBuilder(T); - - impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`Worker_DumpResponse` variant](Body#variant.WorkerDumpResponse). - #[inline] - pub fn worker_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Worker_ResourceUsageResponse` variant](Body#variant.WorkerResourceUsageResponse). - #[inline] - pub fn worker_resource_usage_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcServer_DumpResponse` variant](Body#variant.WebRtcServerDumpResponse). - #[inline] - pub fn web_rtc_server_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Router_DumpResponse` variant](Body#variant.RouterDumpResponse). - #[inline] - pub fn router_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_ProduceResponse` variant](Body#variant.TransportProduceResponse). - #[inline] - pub fn transport_produce_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_ConsumeResponse` variant](Body#variant.TransportConsumeResponse). - #[inline] - pub fn transport_consume_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Transport_RestartIceResponse` variant](Body#variant.TransportRestartIceResponse). - #[inline] - pub fn transport_restart_ice_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PlainTransport_ConnectResponse` variant](Body#variant.PlainTransportConnectResponse). - #[inline] - pub fn plain_transport_connect_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PlainTransport_DumpResponse` variant](Body#variant.PlainTransportDumpResponse). - #[inline] - pub fn plain_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PlainTransport_GetStatsResponse` variant](Body#variant.PlainTransportGetStatsResponse). - #[inline] - pub fn plain_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PipeTransport_ConnectResponse` variant](Body#variant.PipeTransportConnectResponse). - #[inline] - pub fn pipe_transport_connect_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PipeTransport_DumpResponse` variant](Body#variant.PipeTransportDumpResponse). - #[inline] - pub fn pipe_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PipeTransport_GetStatsResponse` variant](Body#variant.PipeTransportGetStatsResponse). - #[inline] - pub fn pipe_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DirectTransport_DumpResponse` variant](Body#variant.DirectTransportDumpResponse). - #[inline] - pub fn direct_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DirectTransport_GetStatsResponse` variant](Body#variant.DirectTransportGetStatsResponse). - #[inline] - pub fn direct_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_ConnectResponse` variant](Body#variant.WebRtcTransportConnectResponse). - #[inline] - pub fn web_rtc_transport_connect_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_DumpResponse` variant](Body#variant.WebRtcTransportDumpResponse). - #[inline] - pub fn web_rtc_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`WebRtcTransport_GetStatsResponse` variant](Body#variant.WebRtcTransportGetStatsResponse). - #[inline] - pub fn web_rtc_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_DumpResponse` variant](Body#variant.ProducerDumpResponse). - #[inline] - pub fn producer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Producer_GetStatsResponse` variant](Body#variant.ProducerGetStatsResponse). - #[inline] - pub fn producer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_DumpResponse` variant](Body#variant.ConsumerDumpResponse). - #[inline] - pub fn consumer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_GetStatsResponse` variant](Body#variant.ConsumerGetStatsResponse). - #[inline] - pub fn consumer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_SetPreferredLayersResponse` variant](Body#variant.ConsumerSetPreferredLayersResponse). - #[inline] - pub fn consumer_set_preferred_layers_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`Consumer_SetPriorityResponse` variant](Body#variant.ConsumerSetPriorityResponse). - #[inline] - pub fn consumer_set_priority_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataProducer_DumpResponse` variant](Body#variant.DataProducerDumpResponse). - #[inline] - pub fn data_producer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataProducer_GetStatsResponse` variant](Body#variant.DataProducerGetStatsResponse). - #[inline] - pub fn data_producer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_GetBufferedAmountResponse` variant](Body#variant.DataConsumerGetBufferedAmountResponse). - #[inline] - pub fn data_consumer_get_buffered_amount_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_DumpResponse` variant](Body#variant.DataConsumerDumpResponse). - #[inline] - pub fn data_consumer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_GetStatsResponse` variant](Body#variant.DataConsumerGetStatsResponse). - #[inline] - pub fn data_consumer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DataConsumer_SetSubchannelsResponse` variant](Body#variant.DataConsumerSetSubchannelsResponse). - #[inline] - pub fn data_consumer_set_subchannels_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - } - - impl BodyBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - WorkerDumpResponse(super::worker::DumpResponseRef<'a>), - WorkerResourceUsageResponse(super::worker::ResourceUsageResponseRef<'a>), - WebRtcServerDumpResponse(super::web_rtc_server::DumpResponseRef<'a>), - RouterDumpResponse(super::router::DumpResponseRef<'a>), - TransportProduceResponse(super::transport::ProduceResponseRef<'a>), - TransportConsumeResponse(super::transport::ConsumeResponseRef<'a>), - TransportRestartIceResponse(super::transport::RestartIceResponseRef<'a>), - PlainTransportConnectResponse(super::plain_transport::ConnectResponseRef<'a>), - PlainTransportDumpResponse(super::plain_transport::DumpResponseRef<'a>), - PlainTransportGetStatsResponse(super::plain_transport::GetStatsResponseRef<'a>), - PipeTransportConnectResponse(super::pipe_transport::ConnectResponseRef<'a>), - PipeTransportDumpResponse(super::pipe_transport::DumpResponseRef<'a>), - PipeTransportGetStatsResponse(super::pipe_transport::GetStatsResponseRef<'a>), - DirectTransportDumpResponse(super::direct_transport::DumpResponseRef<'a>), - DirectTransportGetStatsResponse(super::direct_transport::GetStatsResponseRef<'a>), - WebRtcTransportConnectResponse(super::web_rtc_transport::ConnectResponseRef<'a>), - WebRtcTransportDumpResponse(super::web_rtc_transport::DumpResponseRef<'a>), - WebRtcTransportGetStatsResponse(super::web_rtc_transport::GetStatsResponseRef<'a>), - ProducerDumpResponse(super::producer::DumpResponseRef<'a>), - ProducerGetStatsResponse(super::producer::GetStatsResponseRef<'a>), - ConsumerDumpResponse(super::consumer::DumpResponseRef<'a>), - ConsumerGetStatsResponse(super::consumer::GetStatsResponseRef<'a>), - ConsumerSetPreferredLayersResponse( - super::consumer::SetPreferredLayersResponseRef<'a>, - ), - ConsumerSetPriorityResponse(super::consumer::SetPriorityResponseRef<'a>), - DataProducerDumpResponse(super::data_producer::DumpResponseRef<'a>), - DataProducerGetStatsResponse(super::data_producer::GetStatsResponseRef<'a>), - DataConsumerGetBufferedAmountResponse( - super::data_consumer::GetBufferedAmountResponseRef<'a>, - ), - DataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), - DataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'a>), - DataConsumerSetSubchannelsResponse( - super::data_consumer::SetSubchannelsResponseRef<'a>, - ), - } - - impl<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; - - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::WorkerDumpResponse(value) => { - Self::WorkerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WorkerResourceUsageResponse(value) => { - Self::WorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WebRtcServerDumpResponse(value) => { - Self::WebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::RouterDumpResponse(value) => { - Self::RouterDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportProduceResponse(value) => { - Self::TransportProduceResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportConsumeResponse(value) => { - Self::TransportConsumeResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::TransportRestartIceResponse(value) => { - Self::TransportRestartIceResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PlainTransportConnectResponse(value) => { - Self::PlainTransportConnectResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PlainTransportDumpResponse(value) => { - Self::PlainTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PlainTransportGetStatsResponse(value) => { - Self::PlainTransportGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PipeTransportConnectResponse(value) => { - Self::PipeTransportConnectResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PipeTransportDumpResponse(value) => { - Self::PipeTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::PipeTransportGetStatsResponse(value) => { - Self::PipeTransportGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DirectTransportDumpResponse(value) => { - Self::DirectTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DirectTransportGetStatsResponse(value) => { - Self::DirectTransportGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WebRtcTransportConnectResponse(value) => { - Self::WebRtcTransportConnectResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WebRtcTransportDumpResponse(value) => { - Self::WebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::WebRtcTransportGetStatsResponse(value) => { - Self::WebRtcTransportGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ProducerDumpResponse(value) => { - Self::ProducerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ProducerGetStatsResponse(value) => { - Self::ProducerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerDumpResponse(value) => { - Self::ConsumerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerGetStatsResponse(value) => { - Self::ConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::ConsumerSetPreferredLayersResponse(value) => { - Self::ConsumerSetPreferredLayersResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::ConsumerSetPriorityResponse(value) => { - Self::ConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataProducerDumpResponse(value) => { - Self::DataProducerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataProducerGetStatsResponse(value) => { - Self::DataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerGetBufferedAmountResponse(value) => { - Self::DataConsumerGetBufferedAmountResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::DataConsumerDumpResponse(value) => { - Self::DataConsumerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerGetStatsResponse(value) => { - Self::DataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::DataConsumerSetSubchannelsResponse(value) => { - Self::DataConsumerSetSubchannelsResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for BodyRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::WorkerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::WorkerResourceUsageResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::WebRtcServerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::RouterDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::TransportProduceResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok(Self::TransportConsumeResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 7 => ::core::result::Result::Ok(Self::TransportRestartIceResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 8 => ::core::result::Result::Ok(Self::PlainTransportConnectResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 9 => ::core::result::Result::Ok(Self::PlainTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 10 => ::core::result::Result::Ok(Self::PlainTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 11 => ::core::result::Result::Ok(Self::PipeTransportConnectResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 12 => ::core::result::Result::Ok(Self::PipeTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 13 => ::core::result::Result::Ok(Self::PipeTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => ::core::result::Result::Ok(Self::DirectTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 15 => ::core::result::Result::Ok(Self::DirectTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 16 => ::core::result::Result::Ok(Self::WebRtcTransportConnectResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 17 => ::core::result::Result::Ok(Self::WebRtcTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 18 => ::core::result::Result::Ok(Self::WebRtcTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 19 => ::core::result::Result::Ok(Self::ProducerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 20 => ::core::result::Result::Ok(Self::ProducerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 21 => ::core::result::Result::Ok(Self::ConsumerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 22 => ::core::result::Result::Ok(Self::ConsumerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 23 => ::core::result::Result::Ok(Self::ConsumerSetPreferredLayersResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 24 => ::core::result::Result::Ok(Self::ConsumerSetPriorityResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 25 => ::core::result::Result::Ok(Self::DataProducerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 26 => ::core::result::Result::Ok(Self::DataProducerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 27 => { - ::core::result::Result::Ok(Self::DataConsumerGetBufferedAmountResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 28 => ::core::result::Result::Ok(Self::DataConsumerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 29 => ::core::result::Result::Ok(Self::DataConsumerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 30 => ::core::result::Result::Ok(Self::DataConsumerSetSubchannelsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `Response` in the namespace `FBS.Response` - /// - /// Generated from these locations: - /// * Table `Response` in the file `../worker/fbs/response.fbs:45` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct Response { - /// The field `id` in the table `Response` - pub id: u32, - /// The field `accepted` in the table `Response` - pub accepted: bool, - /// The field `body` in the table `Response` - pub body: ::core::option::Option, - /// The field `error` in the table `Response` - pub error: ::core::option::Option<::planus::alloc::string::String>, - /// The field `reason` in the table `Response` - pub reason: ::core::option::Option<::planus::alloc::string::String>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Response { - fn default() -> Self { - Self { - id: 0, - accepted: false, - body: ::core::default::Default::default(), - error: ::core::default::Default::default(), - reason: ::core::default::Default::default(), - } - } - } - - impl Response { - /// Creates a [ResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ResponseBuilder<()> { - ResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAsDefault, - field_accepted: impl ::planus::WriteAsDefault, - field_body: impl ::planus::WriteAsOptionalUnion, - field_error: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_reason: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder, &0); - let prepared_accepted = field_accepted.prepare(builder, &false); - let prepared_body = field_body.prepare(builder); - let prepared_error = field_error.prepare(builder); - let prepared_reason = field_reason.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - if prepared_id.is_some() { - table_writer.write_entry::(0); - } - if prepared_body.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_error.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_reason.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - if prepared_accepted.is_some() { - table_writer.write_entry::(1); - } - if prepared_body.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_id) = prepared_id { - object_writer.write::<_, _, 4>(&prepared_id); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - object_writer.write::<_, _, 4>(&prepared_body.offset()); - } - if let ::core::option::Option::Some(prepared_error) = prepared_error { - object_writer.write::<_, _, 4>(&prepared_error); - } - if let ::core::option::Option::Some(prepared_reason) = prepared_reason { - object_writer.write::<_, _, 4>(&prepared_reason); - } - if let ::core::option::Option::Some(prepared_accepted) = - prepared_accepted - { - object_writer.write::<_, _, 1>(&prepared_accepted); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - object_writer.write::<_, _, 1>(&prepared_body.tag()); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Response { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Response { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Response { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Response::create( - builder, - self.id, - self.accepted, - &self.body, - &self.error, - &self.reason, - ) - } - } - - /// Builder for serializing an instance of the [Response] type. - /// - /// Can be created using the [Response::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ResponseBuilder(State); - - impl ResponseBuilder<()> { - /// Setter for the [`id` field](Response#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> ResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ResponseBuilder((value,)) - } - - /// Sets the [`id` field](Response#structfield.id) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn id_as_default(self) -> ResponseBuilder<(::planus::DefaultValue,)> { - self.id(::planus::DefaultValue) - } - } - - impl ResponseBuilder<(T0,)> { - /// Setter for the [`accepted` field](Response#structfield.accepted). - #[inline] - #[allow(clippy::type_complexity)] - pub fn accepted(self, value: T1) -> ResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ResponseBuilder((v0, value)) - } - - /// Sets the [`accepted` field](Response#structfield.accepted) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn accepted_as_default(self) -> ResponseBuilder<(T0, ::planus::DefaultValue)> { - self.accepted(::planus::DefaultValue) - } - } - - impl ResponseBuilder<(T0, T1)> { - /// Setter for the [`body` field](Response#structfield.body). - #[inline] - #[allow(clippy::type_complexity)] - pub fn body(self, value: T2) -> ResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptionalUnion, - { - let (v0, v1) = self.0; - ResponseBuilder((v0, v1, value)) - } - - /// Sets the [`body` field](Response#structfield.body) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn body_as_null(self) -> ResponseBuilder<(T0, T1, ())> { - self.body(()) - } - } - - impl ResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`error` field](Response#structfield.error). - #[inline] - #[allow(clippy::type_complexity)] - pub fn error(self, value: T3) -> ResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2) = self.0; - ResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`error` field](Response#structfield.error) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn error_as_null(self) -> ResponseBuilder<(T0, T1, T2, ())> { - self.error(()) - } - } - - impl ResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`reason` field](Response#structfield.reason). - #[inline] - #[allow(clippy::type_complexity)] - pub fn reason(self, value: T4) -> ResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1, v2, v3) = self.0; - ResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`reason` field](Response#structfield.reason) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn reason_as_null(self) -> ResponseBuilder<(T0, T1, T2, T3, ())> { - self.reason(()) - } - } - - impl ResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Response]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAs<::planus::Offset> - for ResponseBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOptional<::planus::Offset> - for ResponseBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOffset for ResponseBuilder<(T0, T1, T2, T3, T4)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3, v4) = &self.0; - Response::create(builder, v0, v1, v2, v3, v4) - } - } - - /// Reference to a deserialized [Response]. - #[derive(Copy, Clone)] - pub struct ResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ResponseRef<'a> { - /// Getter for the [`id` field](Response#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "Response", "id")?.unwrap_or(0)) - } - - /// Getter for the [`accepted` field](Response#structfield.accepted). - #[inline] - pub fn accepted(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "Response", "accepted")?.unwrap_or(false), - ) - } - - /// Getter for the [`body` field](Response#structfield.body). - #[inline] - pub fn body(&self) -> ::planus::Result<::core::option::Option>> { - self.0.access_union(2, "Response", "body") - } - - /// Getter for the [`error` field](Response#structfield.error). - #[inline] - pub fn error( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(4, "Response", "error") - } - - /// Getter for the [`reason` field](Response#structfield.reason). - #[inline] - pub fn reason( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(5, "Response", "reason") - } - } - - impl<'a> ::core::fmt::Debug for ResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ResponseRef"); - f.field("id", &self.id()); - f.field("accepted", &self.accepted()); - if let ::core::option::Option::Some(field_body) = self.body().transpose() { - f.field("body", &field_body); - } - if let ::core::option::Option::Some(field_error) = self.error().transpose() { - f.field("error", &field_error); - } - if let ::core::option::Option::Some(field_reason) = self.reason().transpose() { - f.field("reason", &field_reason); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Response { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - accepted: ::core::convert::TryInto::try_into(value.accepted()?)?, - body: if let ::core::option::Option::Some(body) = value.body()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(body)?) - } else { - ::core::option::Option::None - }, - error: if let ::core::option::Option::Some(error) = value.error()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(error)?) - } else { - ::core::option::Option::None - }, - reason: if let ::core::option::Option::Some(reason) = value.reason()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - reason, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Response { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ResponseRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * File `../worker/fbs/worker.fbs` - pub mod worker { - /// The table `ChannelMessageHandlers` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `ChannelMessageHandlers` in the file `../worker/fbs/worker.fbs:5` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ChannelMessageHandlers { - /// The field `channel_request_handlers` in the table `ChannelMessageHandlers` - pub channel_request_handlers: - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `channel_notification_handlers` in the table `ChannelMessageHandlers` - pub channel_notification_handlers: - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - } - - impl ChannelMessageHandlers { - /// Creates a [ChannelMessageHandlersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ChannelMessageHandlersBuilder<()> { - ChannelMessageHandlersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_channel_request_handlers: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_channel_notification_handlers: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_channel_request_handlers = - field_channel_request_handlers.prepare(builder); - let prepared_channel_notification_handlers = - field_channel_notification_handlers.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_channel_request_handlers); - object_writer.write::<_, _, 4>(&prepared_channel_notification_handlers); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ChannelMessageHandlers { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for ChannelMessageHandlers - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ChannelMessageHandlers { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ChannelMessageHandlers::create( - builder, - &self.channel_request_handlers, - &self.channel_notification_handlers, - ) - } - } - - /// Builder for serializing an instance of the [ChannelMessageHandlers] type. - /// - /// Can be created using the [ChannelMessageHandlers::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ChannelMessageHandlersBuilder(State); - - impl ChannelMessageHandlersBuilder<()> { - /// Setter for the [`channel_request_handlers` field](ChannelMessageHandlers#structfield.channel_request_handlers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn channel_request_handlers( - self, - value: T0, - ) -> ChannelMessageHandlersBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - ChannelMessageHandlersBuilder((value,)) - } - } - - impl ChannelMessageHandlersBuilder<(T0,)> { - /// Setter for the [`channel_notification_handlers` field](ChannelMessageHandlers#structfield.channel_notification_handlers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn channel_notification_handlers( - self, - value: T1, - ) -> ChannelMessageHandlersBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0,) = self.0; - ChannelMessageHandlersBuilder((v0, value)) - } - } - - impl ChannelMessageHandlersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ChannelMessageHandlers]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> - for ChannelMessageHandlersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for ChannelMessageHandlersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset - for ChannelMessageHandlersBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - ChannelMessageHandlers::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [ChannelMessageHandlers]. - #[derive(Copy, Clone)] - pub struct ChannelMessageHandlersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ChannelMessageHandlersRef<'a> { - /// Getter for the [`channel_request_handlers` field](ChannelMessageHandlers#structfield.channel_request_handlers). - #[inline] - pub fn channel_request_handlers( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0 - .access_required(0, "ChannelMessageHandlers", "channel_request_handlers") - } - - /// Getter for the [`channel_notification_handlers` field](ChannelMessageHandlers#structfield.channel_notification_handlers). - #[inline] - pub fn channel_notification_handlers( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required( - 1, - "ChannelMessageHandlers", - "channel_notification_handlers", - ) - } - } - - impl<'a> ::core::fmt::Debug for ChannelMessageHandlersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ChannelMessageHandlersRef"); - f.field("channel_request_handlers", &self.channel_request_handlers()); - f.field( - "channel_notification_handlers", - &self.channel_notification_handlers(), - ); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ChannelMessageHandlers { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ChannelMessageHandlersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - channel_request_handlers: value - .channel_request_handlers()? - .to_vec_result()?, - channel_notification_handlers: value - .channel_notification_handlers()? - .to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ChannelMessageHandlersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ChannelMessageHandlersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ChannelMessageHandlersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ChannelMessageHandlers { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ChannelMessageHandlersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[ChannelMessageHandlersRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/worker.fbs:10` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `pid` in the table `DumpResponse` - pub pid: u32, - /// The field `web_rtc_server_ids` in the table `DumpResponse` - pub web_rtc_server_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `router_ids` in the table `DumpResponse` - pub router_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `channel_message_handlers` in the table `DumpResponse` - pub channel_message_handlers: - ::planus::alloc::boxed::Box, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_pid: impl ::planus::WriteAsDefault, - field_web_rtc_server_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_router_ids: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - field_channel_message_handlers: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_pid = field_pid.prepare(builder, &0); - let prepared_web_rtc_server_ids = field_web_rtc_server_ids.prepare(builder); - let prepared_router_ids = field_router_ids.prepare(builder); - let prepared_channel_message_handlers = - field_channel_message_handlers.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_pid.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(2); - table_writer.write_entry::<::planus::Offset>(3); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_pid) = prepared_pid { - object_writer.write::<_, _, 4>(&prepared_pid); - } - object_writer.write::<_, _, 4>(&prepared_web_rtc_server_ids); - object_writer.write::<_, _, 4>(&prepared_router_ids); - object_writer.write::<_, _, 4>(&prepared_channel_message_handlers); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - self.pid, - &self.web_rtc_server_ids, - &self.router_ids, - &self.channel_message_handlers, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`pid` field](DumpResponse#structfield.pid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn pid(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - DumpResponseBuilder((value,)) - } - - /// Sets the [`pid` field](DumpResponse#structfield.pid) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn pid_as_default(self) -> DumpResponseBuilder<(::planus::DefaultValue,)> { - self.pid(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`web_rtc_server_ids` field](DumpResponse#structfield.web_rtc_server_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_server_ids(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`router_ids` field](DumpResponse#structfield.router_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn router_ids(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`channel_message_handlers` field](DumpResponse#structfield.channel_message_handlers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn channel_message_handlers( - self, - value: T3, - ) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for DumpResponseBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`pid` field](DumpResponse#structfield.pid). - #[inline] - pub fn pid(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "DumpResponse", "pid")?.unwrap_or(0), - ) - } - - /// Getter for the [`web_rtc_server_ids` field](DumpResponse#structfield.web_rtc_server_ids). - #[inline] - pub fn web_rtc_server_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0 - .access_required(1, "DumpResponse", "web_rtc_server_ids") - } - - /// Getter for the [`router_ids` field](DumpResponse#structfield.router_ids). - #[inline] - pub fn router_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(2, "DumpResponse", "router_ids") - } - - /// Getter for the [`channel_message_handlers` field](DumpResponse#structfield.channel_message_handlers). - #[inline] - pub fn channel_message_handlers( - &self, - ) -> ::planus::Result> { - self.0 - .access_required(3, "DumpResponse", "channel_message_handlers") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("pid", &self.pid()); - f.field("web_rtc_server_ids", &self.web_rtc_server_ids()); - f.field("router_ids", &self.router_ids()); - f.field("channel_message_handlers", &self.channel_message_handlers()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - pid: ::core::convert::TryInto::try_into(value.pid()?)?, - web_rtc_server_ids: value.web_rtc_server_ids()?.to_vec_result()?, - router_ids: value.router_ids()?.to_vec_result()?, - channel_message_handlers: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.channel_message_handlers()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `ResourceUsageResponse` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `ResourceUsageResponse` in the file `../worker/fbs/worker.fbs:17` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ResourceUsageResponse { - /// The field `ru_utime` in the table `ResourceUsageResponse` - pub ru_utime: u64, - /// The field `ru_stime` in the table `ResourceUsageResponse` - pub ru_stime: u64, - /// The field `ru_maxrss` in the table `ResourceUsageResponse` - pub ru_maxrss: u64, - /// The field `ru_ixrss` in the table `ResourceUsageResponse` - pub ru_ixrss: u64, - /// The field `ru_idrss` in the table `ResourceUsageResponse` - pub ru_idrss: u64, - /// The field `ru_isrss` in the table `ResourceUsageResponse` - pub ru_isrss: u64, - /// The field `ru_minflt` in the table `ResourceUsageResponse` - pub ru_minflt: u64, - /// The field `ru_majflt` in the table `ResourceUsageResponse` - pub ru_majflt: u64, - /// The field `ru_nswap` in the table `ResourceUsageResponse` - pub ru_nswap: u64, - /// The field `ru_inblock` in the table `ResourceUsageResponse` - pub ru_inblock: u64, - /// The field `ru_oublock` in the table `ResourceUsageResponse` - pub ru_oublock: u64, - /// The field `ru_msgsnd` in the table `ResourceUsageResponse` - pub ru_msgsnd: u64, - /// The field `ru_msgrcv` in the table `ResourceUsageResponse` - pub ru_msgrcv: u64, - /// The field `ru_nsignals` in the table `ResourceUsageResponse` - pub ru_nsignals: u64, - /// The field `ru_nvcsw` in the table `ResourceUsageResponse` - pub ru_nvcsw: u64, - /// The field `ru_nivcsw` in the table `ResourceUsageResponse` - pub ru_nivcsw: u64, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ResourceUsageResponse { - fn default() -> Self { - Self { - ru_utime: 0, - ru_stime: 0, - ru_maxrss: 0, - ru_ixrss: 0, - ru_idrss: 0, - ru_isrss: 0, - ru_minflt: 0, - ru_majflt: 0, - ru_nswap: 0, - ru_inblock: 0, - ru_oublock: 0, - ru_msgsnd: 0, - ru_msgrcv: 0, - ru_nsignals: 0, - ru_nvcsw: 0, - ru_nivcsw: 0, - } - } - } - - impl ResourceUsageResponse { - /// Creates a [ResourceUsageResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ResourceUsageResponseBuilder<()> { - ResourceUsageResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ru_utime: impl ::planus::WriteAsDefault, - field_ru_stime: impl ::planus::WriteAsDefault, - field_ru_maxrss: impl ::planus::WriteAsDefault, - field_ru_ixrss: impl ::planus::WriteAsDefault, - field_ru_idrss: impl ::planus::WriteAsDefault, - field_ru_isrss: impl ::planus::WriteAsDefault, - field_ru_minflt: impl ::planus::WriteAsDefault, - field_ru_majflt: impl ::planus::WriteAsDefault, - field_ru_nswap: impl ::planus::WriteAsDefault, - field_ru_inblock: impl ::planus::WriteAsDefault, - field_ru_oublock: impl ::planus::WriteAsDefault, - field_ru_msgsnd: impl ::planus::WriteAsDefault, - field_ru_msgrcv: impl ::planus::WriteAsDefault, - field_ru_nsignals: impl ::planus::WriteAsDefault, - field_ru_nvcsw: impl ::planus::WriteAsDefault, - field_ru_nivcsw: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ru_utime = field_ru_utime.prepare(builder, &0); - let prepared_ru_stime = field_ru_stime.prepare(builder, &0); - let prepared_ru_maxrss = field_ru_maxrss.prepare(builder, &0); - let prepared_ru_ixrss = field_ru_ixrss.prepare(builder, &0); - let prepared_ru_idrss = field_ru_idrss.prepare(builder, &0); - let prepared_ru_isrss = field_ru_isrss.prepare(builder, &0); - let prepared_ru_minflt = field_ru_minflt.prepare(builder, &0); - let prepared_ru_majflt = field_ru_majflt.prepare(builder, &0); - let prepared_ru_nswap = field_ru_nswap.prepare(builder, &0); - let prepared_ru_inblock = field_ru_inblock.prepare(builder, &0); - let prepared_ru_oublock = field_ru_oublock.prepare(builder, &0); - let prepared_ru_msgsnd = field_ru_msgsnd.prepare(builder, &0); - let prepared_ru_msgrcv = field_ru_msgrcv.prepare(builder, &0); - let prepared_ru_nsignals = field_ru_nsignals.prepare(builder, &0); - let prepared_ru_nvcsw = field_ru_nvcsw.prepare(builder, &0); - let prepared_ru_nivcsw = field_ru_nivcsw.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<36> = - ::core::default::Default::default(); - if prepared_ru_utime.is_some() { - table_writer.write_entry::(0); - } - if prepared_ru_stime.is_some() { - table_writer.write_entry::(1); - } - if prepared_ru_maxrss.is_some() { - table_writer.write_entry::(2); - } - if prepared_ru_ixrss.is_some() { - table_writer.write_entry::(3); - } - if prepared_ru_idrss.is_some() { - table_writer.write_entry::(4); - } - if prepared_ru_isrss.is_some() { - table_writer.write_entry::(5); - } - if prepared_ru_minflt.is_some() { - table_writer.write_entry::(6); - } - if prepared_ru_majflt.is_some() { - table_writer.write_entry::(7); - } - if prepared_ru_nswap.is_some() { - table_writer.write_entry::(8); - } - if prepared_ru_inblock.is_some() { - table_writer.write_entry::(9); - } - if prepared_ru_oublock.is_some() { - table_writer.write_entry::(10); - } - if prepared_ru_msgsnd.is_some() { - table_writer.write_entry::(11); - } - if prepared_ru_msgrcv.is_some() { - table_writer.write_entry::(12); - } - if prepared_ru_nsignals.is_some() { - table_writer.write_entry::(13); - } - if prepared_ru_nvcsw.is_some() { - table_writer.write_entry::(14); - } - if prepared_ru_nivcsw.is_some() { - table_writer.write_entry::(15); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ru_utime) = - prepared_ru_utime - { - object_writer.write::<_, _, 8>(&prepared_ru_utime); - } - if let ::core::option::Option::Some(prepared_ru_stime) = - prepared_ru_stime - { - object_writer.write::<_, _, 8>(&prepared_ru_stime); - } - if let ::core::option::Option::Some(prepared_ru_maxrss) = - prepared_ru_maxrss - { - object_writer.write::<_, _, 8>(&prepared_ru_maxrss); - } - if let ::core::option::Option::Some(prepared_ru_ixrss) = - prepared_ru_ixrss - { - object_writer.write::<_, _, 8>(&prepared_ru_ixrss); - } - if let ::core::option::Option::Some(prepared_ru_idrss) = - prepared_ru_idrss - { - object_writer.write::<_, _, 8>(&prepared_ru_idrss); - } - if let ::core::option::Option::Some(prepared_ru_isrss) = - prepared_ru_isrss - { - object_writer.write::<_, _, 8>(&prepared_ru_isrss); - } - if let ::core::option::Option::Some(prepared_ru_minflt) = - prepared_ru_minflt - { - object_writer.write::<_, _, 8>(&prepared_ru_minflt); - } - if let ::core::option::Option::Some(prepared_ru_majflt) = - prepared_ru_majflt - { - object_writer.write::<_, _, 8>(&prepared_ru_majflt); - } - if let ::core::option::Option::Some(prepared_ru_nswap) = - prepared_ru_nswap - { - object_writer.write::<_, _, 8>(&prepared_ru_nswap); - } - if let ::core::option::Option::Some(prepared_ru_inblock) = - prepared_ru_inblock - { - object_writer.write::<_, _, 8>(&prepared_ru_inblock); - } - if let ::core::option::Option::Some(prepared_ru_oublock) = - prepared_ru_oublock - { - object_writer.write::<_, _, 8>(&prepared_ru_oublock); - } - if let ::core::option::Option::Some(prepared_ru_msgsnd) = - prepared_ru_msgsnd - { - object_writer.write::<_, _, 8>(&prepared_ru_msgsnd); - } - if let ::core::option::Option::Some(prepared_ru_msgrcv) = - prepared_ru_msgrcv - { - object_writer.write::<_, _, 8>(&prepared_ru_msgrcv); - } - if let ::core::option::Option::Some(prepared_ru_nsignals) = - prepared_ru_nsignals - { - object_writer.write::<_, _, 8>(&prepared_ru_nsignals); - } - if let ::core::option::Option::Some(prepared_ru_nvcsw) = - prepared_ru_nvcsw - { - object_writer.write::<_, _, 8>(&prepared_ru_nvcsw); - } - if let ::core::option::Option::Some(prepared_ru_nivcsw) = - prepared_ru_nivcsw - { - object_writer.write::<_, _, 8>(&prepared_ru_nivcsw); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ResourceUsageResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ResourceUsageResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ResourceUsageResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ResourceUsageResponse::create( - builder, - self.ru_utime, - self.ru_stime, - self.ru_maxrss, - self.ru_ixrss, - self.ru_idrss, - self.ru_isrss, - self.ru_minflt, - self.ru_majflt, - self.ru_nswap, - self.ru_inblock, - self.ru_oublock, - self.ru_msgsnd, - self.ru_msgrcv, - self.ru_nsignals, - self.ru_nvcsw, - self.ru_nivcsw, - ) - } - } - - /// Builder for serializing an instance of the [ResourceUsageResponse] type. - /// - /// Can be created using the [ResourceUsageResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ResourceUsageResponseBuilder(State); - - impl ResourceUsageResponseBuilder<()> { - /// Setter for the [`ru_utime` field](ResourceUsageResponse#structfield.ru_utime). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_utime(self, value: T0) -> ResourceUsageResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ResourceUsageResponseBuilder((value,)) - } - - /// Sets the [`ru_utime` field](ResourceUsageResponse#structfield.ru_utime) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_utime_as_default( - self, - ) -> ResourceUsageResponseBuilder<(::planus::DefaultValue,)> { - self.ru_utime(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0,)> { - /// Setter for the [`ru_stime` field](ResourceUsageResponse#structfield.ru_stime). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_stime(self, value: T1) -> ResourceUsageResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ResourceUsageResponseBuilder((v0, value)) - } - - /// Sets the [`ru_stime` field](ResourceUsageResponse#structfield.ru_stime) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_stime_as_default( - self, - ) -> ResourceUsageResponseBuilder<(T0, ::planus::DefaultValue)> { - self.ru_stime(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0, T1)> { - /// Setter for the [`ru_maxrss` field](ResourceUsageResponse#structfield.ru_maxrss). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_maxrss(self, value: T2) -> ResourceUsageResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - ResourceUsageResponseBuilder((v0, v1, value)) - } - - /// Sets the [`ru_maxrss` field](ResourceUsageResponse#structfield.ru_maxrss) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_maxrss_as_default( - self, - ) -> ResourceUsageResponseBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.ru_maxrss(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_ixrss( - self, - value: T3, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_ixrss_as_default( - self, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, ::planus::DefaultValue)> - { - self.ru_ixrss(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`ru_idrss` field](ResourceUsageResponse#structfield.ru_idrss). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_idrss( - self, - value: T4, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`ru_idrss` field](ResourceUsageResponse#structfield.ru_idrss) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_idrss_as_default( - self, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.ru_idrss(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`ru_isrss` field](ResourceUsageResponse#structfield.ru_isrss). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_isrss( - self, - value: T5, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`ru_isrss` field](ResourceUsageResponse#structfield.ru_isrss) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_isrss_as_default( - self, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.ru_isrss(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_minflt( - self, - value: T6, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_minflt_as_default( - self, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.ru_minflt(::planus::DefaultValue) - } - } - - impl ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_majflt( - self, - value: T7, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_majflt_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - ::planus::DefaultValue, - )> { - self.ru_majflt(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - /// Setter for the [`ru_nswap` field](ResourceUsageResponse#structfield.ru_nswap). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nswap( - self, - value: T8, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - where - T8: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) - } - - /// Sets the [`ru_nswap` field](ResourceUsageResponse#structfield.ru_nswap) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nswap_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - ::planus::DefaultValue, - )> { - self.ru_nswap(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - /// Setter for the [`ru_inblock` field](ResourceUsageResponse#structfield.ru_inblock). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_inblock( - self, - value: T9, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - where - T9: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) - } - - /// Sets the [`ru_inblock` field](ResourceUsageResponse#structfield.ru_inblock) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_inblock_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - ::planus::DefaultValue, - )> { - self.ru_inblock(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { - /// Setter for the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_oublock( - self, - value: T10, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - where - T10: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, value)) - } - - /// Sets the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_oublock_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - ::planus::DefaultValue, - )> { - self.ru_oublock(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> - { - /// Setter for the [`ru_msgsnd` field](ResourceUsageResponse#structfield.ru_msgsnd). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_msgsnd( - self, - value: T11, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - where - T11: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) = self.0; - ResourceUsageResponseBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, value, - )) - } - - /// Sets the [`ru_msgsnd` field](ResourceUsageResponse#structfield.ru_msgsnd) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_msgsnd_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - ::planus::DefaultValue, - )> { - self.ru_msgsnd(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_msgrcv( - self, - value: T12, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - )> - where - T12: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) = self.0; - ResourceUsageResponseBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, value, - )) - } - - /// Sets the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_msgrcv_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - ::planus::DefaultValue, - )> { - self.ru_msgrcv(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - )> - { - /// Setter for the [`ru_nsignals` field](ResourceUsageResponse#structfield.ru_nsignals). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nsignals( - self, - value: T13, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - )> - where - T13: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) = self.0; - ResourceUsageResponseBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, value, - )) - } - - /// Sets the [`ru_nsignals` field](ResourceUsageResponse#structfield.ru_nsignals) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nsignals_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - ::planus::DefaultValue, - )> { - self.ru_nsignals(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - )> - { - /// Setter for the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nvcsw( - self, - value: T14, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - where - T14: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) = self.0; - ResourceUsageResponseBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, value, - )) - } - - /// Sets the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nvcsw_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - ::planus::DefaultValue, - )> { - self.ru_nvcsw(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - )> - { - /// Setter for the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nivcsw( - self, - value: T15, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - where - T15: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) = self.0; - ResourceUsageResponseBuilder(( - v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, value, - )) - } - - /// Sets the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_nivcsw_as_default( - self, - ) -> ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - ::planus::DefaultValue, - )> { - self.ru_nivcsw(::planus::DefaultValue) - } - } - - impl - ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ResourceUsageResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - T10: ::planus::WriteAsDefault, - T11: ::planus::WriteAsDefault, - T12: ::planus::WriteAsDefault, - T13: ::planus::WriteAsDefault, - T14: ::planus::WriteAsDefault, - T15: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - )> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) = - &self.0; - ResourceUsageResponse::create( - builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, - v15, - ) - } - } - - /// Reference to a deserialized [ResourceUsageResponse]. - #[derive(Copy, Clone)] - pub struct ResourceUsageResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ResourceUsageResponseRef<'a> { - /// Getter for the [`ru_utime` field](ResourceUsageResponse#structfield.ru_utime). - #[inline] - pub fn ru_utime(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ResourceUsageResponse", "ru_utime")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_stime` field](ResourceUsageResponse#structfield.ru_stime). - #[inline] - pub fn ru_stime(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "ResourceUsageResponse", "ru_stime")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_maxrss` field](ResourceUsageResponse#structfield.ru_maxrss). - #[inline] - pub fn ru_maxrss(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "ResourceUsageResponse", "ru_maxrss")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss). - #[inline] - pub fn ru_ixrss(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "ResourceUsageResponse", "ru_ixrss")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_idrss` field](ResourceUsageResponse#structfield.ru_idrss). - #[inline] - pub fn ru_idrss(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "ResourceUsageResponse", "ru_idrss")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_isrss` field](ResourceUsageResponse#structfield.ru_isrss). - #[inline] - pub fn ru_isrss(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "ResourceUsageResponse", "ru_isrss")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt). - #[inline] - pub fn ru_minflt(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "ResourceUsageResponse", "ru_minflt")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt). - #[inline] - pub fn ru_majflt(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "ResourceUsageResponse", "ru_majflt")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_nswap` field](ResourceUsageResponse#structfield.ru_nswap). - #[inline] - pub fn ru_nswap(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(8, "ResourceUsageResponse", "ru_nswap")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_inblock` field](ResourceUsageResponse#structfield.ru_inblock). - #[inline] - pub fn ru_inblock(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(9, "ResourceUsageResponse", "ru_inblock")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock). - #[inline] - pub fn ru_oublock(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(10, "ResourceUsageResponse", "ru_oublock")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_msgsnd` field](ResourceUsageResponse#structfield.ru_msgsnd). - #[inline] - pub fn ru_msgsnd(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(11, "ResourceUsageResponse", "ru_msgsnd")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv). - #[inline] - pub fn ru_msgrcv(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(12, "ResourceUsageResponse", "ru_msgrcv")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_nsignals` field](ResourceUsageResponse#structfield.ru_nsignals). - #[inline] - pub fn ru_nsignals(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(13, "ResourceUsageResponse", "ru_nsignals")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw). - #[inline] - pub fn ru_nvcsw(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(14, "ResourceUsageResponse", "ru_nvcsw")? - .unwrap_or(0), - ) - } - - /// Getter for the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw). - #[inline] - pub fn ru_nivcsw(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(15, "ResourceUsageResponse", "ru_nivcsw")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for ResourceUsageResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ResourceUsageResponseRef"); - f.field("ru_utime", &self.ru_utime()); - f.field("ru_stime", &self.ru_stime()); - f.field("ru_maxrss", &self.ru_maxrss()); - f.field("ru_ixrss", &self.ru_ixrss()); - f.field("ru_idrss", &self.ru_idrss()); - f.field("ru_isrss", &self.ru_isrss()); - f.field("ru_minflt", &self.ru_minflt()); - f.field("ru_majflt", &self.ru_majflt()); - f.field("ru_nswap", &self.ru_nswap()); - f.field("ru_inblock", &self.ru_inblock()); - f.field("ru_oublock", &self.ru_oublock()); - f.field("ru_msgsnd", &self.ru_msgsnd()); - f.field("ru_msgrcv", &self.ru_msgrcv()); - f.field("ru_nsignals", &self.ru_nsignals()); - f.field("ru_nvcsw", &self.ru_nvcsw()); - f.field("ru_nivcsw", &self.ru_nivcsw()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ResourceUsageResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ResourceUsageResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ru_utime: ::core::convert::TryInto::try_into(value.ru_utime()?)?, - ru_stime: ::core::convert::TryInto::try_into(value.ru_stime()?)?, - ru_maxrss: ::core::convert::TryInto::try_into(value.ru_maxrss()?)?, - ru_ixrss: ::core::convert::TryInto::try_into(value.ru_ixrss()?)?, - ru_idrss: ::core::convert::TryInto::try_into(value.ru_idrss()?)?, - ru_isrss: ::core::convert::TryInto::try_into(value.ru_isrss()?)?, - ru_minflt: ::core::convert::TryInto::try_into(value.ru_minflt()?)?, - ru_majflt: ::core::convert::TryInto::try_into(value.ru_majflt()?)?, - ru_nswap: ::core::convert::TryInto::try_into(value.ru_nswap()?)?, - ru_inblock: ::core::convert::TryInto::try_into(value.ru_inblock()?)?, - ru_oublock: ::core::convert::TryInto::try_into(value.ru_oublock()?)?, - ru_msgsnd: ::core::convert::TryInto::try_into(value.ru_msgsnd()?)?, - ru_msgrcv: ::core::convert::TryInto::try_into(value.ru_msgrcv()?)?, - ru_nsignals: ::core::convert::TryInto::try_into(value.ru_nsignals()?)?, - ru_nvcsw: ::core::convert::TryInto::try_into(value.ru_nvcsw()?)?, - ru_nivcsw: ::core::convert::TryInto::try_into(value.ru_nivcsw()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ResourceUsageResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ResourceUsageResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ResourceUsageResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ResourceUsageResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ResourceUsageResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[ResourceUsageResponseRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `UpdateSettingsRequest` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `UpdateSettingsRequest` in the file `../worker/fbs/worker.fbs:36` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct UpdateSettingsRequest { - /// The field `log_level` in the table `UpdateSettingsRequest` - pub log_level: ::core::option::Option<::planus::alloc::string::String>, - /// The field `log_tags` in the table `UpdateSettingsRequest` - pub log_tags: ::core::option::Option< - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for UpdateSettingsRequest { - fn default() -> Self { - Self { - log_level: ::core::default::Default::default(), - log_tags: ::core::default::Default::default(), - } - } - } - - impl UpdateSettingsRequest { - /// Creates a [UpdateSettingsRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> UpdateSettingsRequestBuilder<()> { - UpdateSettingsRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_log_level: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_log_tags: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_log_level = field_log_level.prepare(builder); - let prepared_log_tags = field_log_tags.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_log_level.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } - if prepared_log_tags.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_log_level) = - prepared_log_level - { - object_writer.write::<_, _, 4>(&prepared_log_level); - } - if let ::core::option::Option::Some(prepared_log_tags) = - prepared_log_tags - { - object_writer.write::<_, _, 4>(&prepared_log_tags); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for UpdateSettingsRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for UpdateSettingsRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for UpdateSettingsRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - UpdateSettingsRequest::create(builder, &self.log_level, &self.log_tags) - } - } - - /// Builder for serializing an instance of the [UpdateSettingsRequest] type. - /// - /// Can be created using the [UpdateSettingsRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct UpdateSettingsRequestBuilder(State); - - impl UpdateSettingsRequestBuilder<()> { - /// Setter for the [`log_level` field](UpdateSettingsRequest#structfield.log_level). - #[inline] - #[allow(clippy::type_complexity)] - pub fn log_level(self, value: T0) -> UpdateSettingsRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - UpdateSettingsRequestBuilder((value,)) - } - - /// Sets the [`log_level` field](UpdateSettingsRequest#structfield.log_level) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn log_level_as_null(self) -> UpdateSettingsRequestBuilder<((),)> { - self.log_level(()) - } - } - - impl UpdateSettingsRequestBuilder<(T0,)> { - /// Setter for the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags). - #[inline] - #[allow(clippy::type_complexity)] - pub fn log_tags(self, value: T1) -> UpdateSettingsRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - { - let (v0,) = self.0; - UpdateSettingsRequestBuilder((v0, value)) - } - - /// Sets the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn log_tags_as_null(self) -> UpdateSettingsRequestBuilder<(T0, ())> { - self.log_tags(()) - } - } - - impl UpdateSettingsRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [UpdateSettingsRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> - for UpdateSettingsRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for UpdateSettingsRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset - for UpdateSettingsRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - UpdateSettingsRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [UpdateSettingsRequest]. - #[derive(Copy, Clone)] - pub struct UpdateSettingsRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> UpdateSettingsRequestRef<'a> { - /// Getter for the [`log_level` field](UpdateSettingsRequest#structfield.log_level). - #[inline] - pub fn log_level( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "UpdateSettingsRequest", "log_level") - } - - /// Getter for the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags). - #[inline] - pub fn log_tags( - &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, - > { - self.0.access(1, "UpdateSettingsRequest", "log_tags") - } - } - - impl<'a> ::core::fmt::Debug for UpdateSettingsRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("UpdateSettingsRequestRef"); - if let ::core::option::Option::Some(field_log_level) = - self.log_level().transpose() - { - f.field("log_level", &field_log_level); - } - if let ::core::option::Option::Some(field_log_tags) = - self.log_tags().transpose() - { - f.field("log_tags", &field_log_tags); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for UpdateSettingsRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: UpdateSettingsRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - log_level: if let ::core::option::Option::Some(log_level) = - value.log_level()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - log_level, - )?) - } else { - ::core::option::Option::None - }, - log_tags: if let ::core::option::Option::Some(log_tags) = - value.log_tags()? - { - ::core::option::Option::Some(log_tags.to_vec_result()?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for UpdateSettingsRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for UpdateSettingsRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[UpdateSettingsRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for UpdateSettingsRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for UpdateSettingsRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[UpdateSettingsRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreateWebRtcServerRequest` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `CreateWebRtcServerRequest` in the file `../worker/fbs/worker.fbs:41` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreateWebRtcServerRequest { - /// The field `web_rtc_server_id` in the table `CreateWebRtcServerRequest` - pub web_rtc_server_id: ::planus::alloc::string::String, - /// The field `listen_infos` in the table `CreateWebRtcServerRequest` - pub listen_infos: - ::core::option::Option<::planus::alloc::vec::Vec>, - } - - impl CreateWebRtcServerRequest { - /// Creates a [CreateWebRtcServerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreateWebRtcServerRequestBuilder<()> { - CreateWebRtcServerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_web_rtc_server_id: impl ::planus::WriteAs<::planus::Offset>, - field_listen_infos: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); - let prepared_listen_infos = field_listen_infos.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_listen_infos.is_some() { - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); - if let ::core::option::Option::Some(prepared_listen_infos) = - prepared_listen_infos - { - object_writer.write::<_, _, 4>(&prepared_listen_infos); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CreateWebRtcServerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcServerRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreateWebRtcServerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateWebRtcServerRequest::create( - builder, - &self.web_rtc_server_id, - &self.listen_infos, - ) - } - } - - /// Builder for serializing an instance of the [CreateWebRtcServerRequest] type. - /// - /// Can be created using the [CreateWebRtcServerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreateWebRtcServerRequestBuilder(State); - - impl CreateWebRtcServerRequestBuilder<()> { - /// Setter for the [`web_rtc_server_id` field](CreateWebRtcServerRequest#structfield.web_rtc_server_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_server_id( - self, - value: T0, - ) -> CreateWebRtcServerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreateWebRtcServerRequestBuilder((value,)) - } - } - - impl CreateWebRtcServerRequestBuilder<(T0,)> { - /// Setter for the [`listen_infos` field](CreateWebRtcServerRequest#structfield.listen_infos). - #[inline] - #[allow(clippy::type_complexity)] - pub fn listen_infos( - self, - value: T1, - ) -> CreateWebRtcServerRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0,) = self.0; - CreateWebRtcServerRequestBuilder((v0, value)) - } - - /// Sets the [`listen_infos` field](CreateWebRtcServerRequest#structfield.listen_infos) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn listen_infos_as_null(self) -> CreateWebRtcServerRequestBuilder<(T0, ())> { - self.listen_infos(()) - } - } - - impl CreateWebRtcServerRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateWebRtcServerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for CreateWebRtcServerRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcServerRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset - for CreateWebRtcServerRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreateWebRtcServerRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreateWebRtcServerRequest]. - #[derive(Copy, Clone)] - pub struct CreateWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreateWebRtcServerRequestRef<'a> { - /// Getter for the [`web_rtc_server_id` field](CreateWebRtcServerRequest#structfield.web_rtc_server_id). - #[inline] - pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreateWebRtcServerRequest", "web_rtc_server_id") - } - - /// Getter for the [`listen_infos` field](CreateWebRtcServerRequest#structfield.listen_infos). - #[inline] - pub fn listen_infos( - &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0 - .access(1, "CreateWebRtcServerRequest", "listen_infos") - } - } - - impl<'a> ::core::fmt::Debug for CreateWebRtcServerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreateWebRtcServerRequestRef"); - f.field("web_rtc_server_id", &self.web_rtc_server_id()); - if let ::core::option::Option::Some(field_listen_infos) = - self.listen_infos().transpose() - { - f.field("listen_infos", &field_listen_infos); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CreateWebRtcServerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CreateWebRtcServerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - web_rtc_server_id: ::core::convert::TryInto::try_into( - value.web_rtc_server_id()?, - )?, - listen_infos: if let ::core::option::Option::Some(listen_infos) = - value.listen_infos()? - { - ::core::option::Option::Some(listen_infos.to_vec_result()?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreateWebRtcServerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreateWebRtcServerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreateWebRtcServerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreateWebRtcServerRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreateWebRtcServerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateWebRtcServerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseWebRtcServerRequest` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `CloseWebRtcServerRequest` in the file `../worker/fbs/worker.fbs:46` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseWebRtcServerRequest { - /// The field `web_rtc_server_id` in the table `CloseWebRtcServerRequest` - pub web_rtc_server_id: ::planus::alloc::string::String, - } - - impl CloseWebRtcServerRequest { - /// Creates a [CloseWebRtcServerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseWebRtcServerRequestBuilder<()> { - CloseWebRtcServerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_web_rtc_server_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseWebRtcServerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CloseWebRtcServerRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseWebRtcServerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseWebRtcServerRequest::create(builder, &self.web_rtc_server_id) - } - } - - /// Builder for serializing an instance of the [CloseWebRtcServerRequest] type. - /// - /// Can be created using the [CloseWebRtcServerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseWebRtcServerRequestBuilder(State); - - impl CloseWebRtcServerRequestBuilder<()> { - /// Setter for the [`web_rtc_server_id` field](CloseWebRtcServerRequest#structfield.web_rtc_server_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_server_id( - self, - value: T0, - ) -> CloseWebRtcServerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseWebRtcServerRequestBuilder((value,)) - } - } - - impl CloseWebRtcServerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseWebRtcServerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseWebRtcServerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseWebRtcServerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseWebRtcServerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseWebRtcServerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseWebRtcServerRequest]. - #[derive(Copy, Clone)] - pub struct CloseWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseWebRtcServerRequestRef<'a> { - /// Getter for the [`web_rtc_server_id` field](CloseWebRtcServerRequest#structfield.web_rtc_server_id). - #[inline] - pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseWebRtcServerRequest", "web_rtc_server_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseWebRtcServerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseWebRtcServerRequestRef"); - f.field("web_rtc_server_id", &self.web_rtc_server_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseWebRtcServerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseWebRtcServerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - web_rtc_server_id: ::core::convert::TryInto::try_into( - value.web_rtc_server_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseWebRtcServerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseWebRtcServerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseWebRtcServerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CloseWebRtcServerRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseWebRtcServerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseWebRtcServerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreateRouterRequest` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `CreateRouterRequest` in the file `../worker/fbs/worker.fbs:50` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreateRouterRequest { - /// The field `router_id` in the table `CreateRouterRequest` - pub router_id: ::planus::alloc::string::String, - } - - impl CreateRouterRequest { - /// Creates a [CreateRouterRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreateRouterRequestBuilder<()> { - CreateRouterRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_router_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_router_id = field_router_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_router_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CreateRouterRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for CreateRouterRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreateRouterRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateRouterRequest::create(builder, &self.router_id) - } - } - - /// Builder for serializing an instance of the [CreateRouterRequest] type. - /// - /// Can be created using the [CreateRouterRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreateRouterRequestBuilder(State); - - impl CreateRouterRequestBuilder<()> { - /// Setter for the [`router_id` field](CreateRouterRequest#structfield.router_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn router_id(self, value: T0) -> CreateRouterRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreateRouterRequestBuilder((value,)) - } - } - - impl CreateRouterRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateRouterRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CreateRouterRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CreateRouterRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for CreateRouterRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CreateRouterRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CreateRouterRequest]. - #[derive(Copy, Clone)] - pub struct CreateRouterRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreateRouterRequestRef<'a> { - /// Getter for the [`router_id` field](CreateRouterRequest#structfield.router_id). - #[inline] - pub fn router_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreateRouterRequest", "router_id") - } - } - - impl<'a> ::core::fmt::Debug for CreateRouterRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreateRouterRequestRef"); - f.field("router_id", &self.router_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CreateRouterRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CreateRouterRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - router_id: ::core::convert::TryInto::try_into(value.router_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreateRouterRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreateRouterRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreateRouterRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CreateRouterRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreateRouterRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateRouterRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseRouterRequest` in the namespace `FBS.Worker` - /// - /// Generated from these locations: - /// * Table `CloseRouterRequest` in the file `../worker/fbs/worker.fbs:54` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseRouterRequest { - /// The field `router_id` in the table `CloseRouterRequest` - pub router_id: ::planus::alloc::string::String, - } - - impl CloseRouterRequest { - /// Creates a [CloseRouterRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseRouterRequestBuilder<()> { - CloseRouterRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_router_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_router_id = field_router_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_router_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseRouterRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for CloseRouterRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseRouterRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseRouterRequest::create(builder, &self.router_id) - } - } - - /// Builder for serializing an instance of the [CloseRouterRequest] type. - /// - /// Can be created using the [CloseRouterRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseRouterRequestBuilder(State); - - impl CloseRouterRequestBuilder<()> { - /// Setter for the [`router_id` field](CloseRouterRequest#structfield.router_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn router_id(self, value: T0) -> CloseRouterRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseRouterRequestBuilder((value,)) - } - } - - impl CloseRouterRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseRouterRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseRouterRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseRouterRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for CloseRouterRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseRouterRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseRouterRequest]. - #[derive(Copy, Clone)] - pub struct CloseRouterRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseRouterRequestRef<'a> { - /// Getter for the [`router_id` field](CloseRouterRequest#structfield.router_id). - #[inline] - pub fn router_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "CloseRouterRequest", "router_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseRouterRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseRouterRequestRef"); - f.field("router_id", &self.router_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseRouterRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseRouterRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - router_id: ::core::convert::TryInto::try_into(value.router_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseRouterRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseRouterRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseRouterRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CloseRouterRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseRouterRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[CloseRouterRequestRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Router` - /// - /// Generated from these locations: - /// * File `../worker/fbs/router.fbs` - pub mod router { - /// The table `DumpResponse` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/router.fbs:12` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `id` in the table `DumpResponse` - pub id: ::planus::alloc::string::String, - /// The field `transport_ids` in the table `DumpResponse` - pub transport_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `rtp_observer_ids` in the table `DumpResponse` - pub rtp_observer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `map_producer_id_consumer_ids` in the table `DumpResponse` - pub map_producer_id_consumer_ids: - ::planus::alloc::vec::Vec, - /// The field `map_consumer_id_producer_id` in the table `DumpResponse` - pub map_consumer_id_producer_id: - ::planus::alloc::vec::Vec, - /// The field `map_producer_id_observer_ids` in the table `DumpResponse` - pub map_producer_id_observer_ids: - ::planus::alloc::vec::Vec, - /// The field `map_data_producer_id_data_consumer_ids` in the table `DumpResponse` - pub map_data_producer_id_data_consumer_ids: - ::planus::alloc::vec::Vec, - /// The field `map_data_consumer_id_data_producer_id` in the table `DumpResponse` - pub map_data_consumer_id_data_producer_id: - ::planus::alloc::vec::Vec, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_transport_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_rtp_observer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_producer_id_consumer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_consumer_id_producer_id: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_producer_id_observer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_data_producer_id_data_consumer_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_map_data_consumer_id_data_producer_id: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_transport_ids = field_transport_ids.prepare(builder); - let prepared_rtp_observer_ids = field_rtp_observer_ids.prepare(builder); - let prepared_map_producer_id_consumer_ids = - field_map_producer_id_consumer_ids.prepare(builder); - let prepared_map_consumer_id_producer_id = - field_map_consumer_id_producer_id.prepare(builder); - let prepared_map_producer_id_observer_ids = - field_map_producer_id_observer_ids.prepare(builder); - let prepared_map_data_producer_id_data_consumer_ids = - field_map_data_producer_id_data_consumer_ids.prepare(builder); - let prepared_map_data_consumer_id_data_producer_id = - field_map_data_consumer_id_data_producer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(2); - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(3); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(4); - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(5); - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(6); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(7); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_transport_ids); - object_writer.write::<_, _, 4>(&prepared_rtp_observer_ids); - object_writer.write::<_, _, 4>(&prepared_map_producer_id_consumer_ids); - object_writer.write::<_, _, 4>(&prepared_map_consumer_id_producer_id); - object_writer.write::<_, _, 4>(&prepared_map_producer_id_observer_ids); - object_writer - .write::<_, _, 4>(&prepared_map_data_producer_id_data_consumer_ids); - object_writer - .write::<_, _, 4>(&prepared_map_data_consumer_id_data_producer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.id, - &self.transport_ids, - &self.rtp_observer_ids, - &self.map_producer_id_consumer_ids, - &self.map_consumer_id_producer_id, - &self.map_producer_id_observer_ids, - &self.map_data_producer_id_data_consumer_ids, - &self.map_data_consumer_id_data_producer_id, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`transport_ids` field](DumpResponse#structfield.transport_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_ids(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`rtp_observer_ids` field](DumpResponse#structfield.rtp_observer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_observer_ids(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`map_producer_id_consumer_ids` field](DumpResponse#structfield.map_producer_id_consumer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_producer_id_consumer_ids( - self, - value: T3, - ) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`map_consumer_id_producer_id` field](DumpResponse#structfield.map_consumer_id_producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_consumer_id_producer_id( - self, - value: T4, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`map_producer_id_observer_ids` field](DumpResponse#structfield.map_producer_id_observer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_producer_id_observer_ids( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`map_data_producer_id_data_consumer_ids` field](DumpResponse#structfield.map_data_producer_id_data_consumer_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_data_producer_id_data_consumer_ids( - self, - value: T6, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`map_data_consumer_id_data_producer_id` field](DumpResponse#structfield.map_data_consumer_id_data_producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn map_data_consumer_id_data_producer_id( - self, - value: T7, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T7: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T7: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T7: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`id` field](DumpResponse#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "DumpResponse", "id") - } - - /// Getter for the [`transport_ids` field](DumpResponse#structfield.transport_ids). - #[inline] - pub fn transport_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0.access_required(1, "DumpResponse", "transport_ids") - } - - /// Getter for the [`rtp_observer_ids` field](DumpResponse#structfield.rtp_observer_ids). - #[inline] - pub fn rtp_observer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0 - .access_required(2, "DumpResponse", "rtp_observer_ids") - } - - /// Getter for the [`map_producer_id_consumer_ids` field](DumpResponse#structfield.map_producer_id_consumer_ids). - #[inline] - pub fn map_producer_id_consumer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(3, "DumpResponse", "map_producer_id_consumer_ids") - } - - /// Getter for the [`map_consumer_id_producer_id` field](DumpResponse#structfield.map_consumer_id_producer_id). - #[inline] - pub fn map_consumer_id_producer_id( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(4, "DumpResponse", "map_consumer_id_producer_id") - } - - /// Getter for the [`map_producer_id_observer_ids` field](DumpResponse#structfield.map_producer_id_observer_ids). - #[inline] - pub fn map_producer_id_observer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(5, "DumpResponse", "map_producer_id_observer_ids") - } - - /// Getter for the [`map_data_producer_id_data_consumer_ids` field](DumpResponse#structfield.map_data_producer_id_data_consumer_ids). - #[inline] - pub fn map_data_producer_id_data_consumer_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required( - 6, - "DumpResponse", - "map_data_producer_id_data_consumer_ids", - ) - } - - /// Getter for the [`map_data_consumer_id_data_producer_id` field](DumpResponse#structfield.map_data_consumer_id_data_producer_id). - #[inline] - pub fn map_data_consumer_id_data_producer_id( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required( - 7, - "DumpResponse", - "map_data_consumer_id_data_producer_id", - ) - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("id", &self.id()); - f.field("transport_ids", &self.transport_ids()); - f.field("rtp_observer_ids", &self.rtp_observer_ids()); - f.field( - "map_producer_id_consumer_ids", - &self.map_producer_id_consumer_ids(), - ); - f.field( - "map_consumer_id_producer_id", - &self.map_consumer_id_producer_id(), - ); - f.field( - "map_producer_id_observer_ids", - &self.map_producer_id_observer_ids(), - ); - f.field( - "map_data_producer_id_data_consumer_ids", - &self.map_data_producer_id_data_consumer_ids(), - ); - f.field( - "map_data_consumer_id_data_producer_id", - &self.map_data_consumer_id_data_producer_id(), - ); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - transport_ids: value.transport_ids()?.to_vec_result()?, - rtp_observer_ids: value.rtp_observer_ids()?.to_vec_result()?, - map_producer_id_consumer_ids: value - .map_producer_id_consumer_ids()? - .to_vec_result()?, - map_consumer_id_producer_id: value - .map_consumer_id_producer_id()? - .to_vec_result()?, - map_producer_id_observer_ids: value - .map_producer_id_observer_ids()? - .to_vec_result()?, - map_data_producer_id_data_consumer_ids: value - .map_data_producer_id_data_consumer_ids()? - .to_vec_result()?, - map_data_consumer_id_data_producer_id: value - .map_data_consumer_id_data_producer_id()? - .to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `CreatePipeTransportRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CreatePipeTransportRequest` in the file `../worker/fbs/router.fbs:23` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreatePipeTransportRequest { - /// The field `transport_id` in the table `CreatePipeTransportRequest` - pub transport_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreatePipeTransportRequest` - pub options: - ::planus::alloc::boxed::Box, - } - - impl CreatePipeTransportRequest { - /// Creates a [CreatePipeTransportRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreatePipeTransportRequestBuilder<()> { - CreatePipeTransportRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); - object_writer.write::<_, _, 4>(&prepared_options); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for CreatePipeTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreatePipeTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreatePipeTransportRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreatePipeTransportRequest::create(builder, &self.transport_id, &self.options) - } - } - - /// Builder for serializing an instance of the [CreatePipeTransportRequest] type. - /// - /// Can be created using the [CreatePipeTransportRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreatePipeTransportRequestBuilder(State); - - impl CreatePipeTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreatePipeTransportRequest#structfield.transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_id(self, value: T0) -> CreatePipeTransportRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreatePipeTransportRequestBuilder((value,)) - } - } - - impl CreatePipeTransportRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreatePipeTransportRequest#structfield.options). - #[inline] - #[allow(clippy::type_complexity)] - pub fn options(self, value: T1) -> CreatePipeTransportRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset, - >, - { - let (v0,) = self.0; - CreatePipeTransportRequestBuilder((v0, value)) - } - } - - impl CreatePipeTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreatePipeTransportRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreatePipeTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for CreatePipeTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for CreatePipeTransportRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreatePipeTransportRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreatePipeTransportRequest]. - #[derive(Copy, Clone)] - pub struct CreatePipeTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreatePipeTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreatePipeTransportRequest#structfield.transport_id). - #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreatePipeTransportRequest", "transport_id") - } - - /// Getter for the [`options` field](CreatePipeTransportRequest#structfield.options). - #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { - self.0 - .access_required(1, "CreatePipeTransportRequest", "options") - } - } - - impl<'a> ::core::fmt::Debug for CreatePipeTransportRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreatePipeTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for CreatePipeTransportRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CreatePipeTransportRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreatePipeTransportRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreatePipeTransportRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreatePipeTransportRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreatePipeTransportRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreatePipeTransportRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreatePipeTransportRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreatePlainTransportRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CreatePlainTransportRequest` in the file `../worker/fbs/router.fbs:28` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreatePlainTransportRequest { - /// The field `transport_id` in the table `CreatePlainTransportRequest` - pub transport_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreatePlainTransportRequest` - pub options: - ::planus::alloc::boxed::Box, - } - - impl CreatePlainTransportRequest { - /// Creates a [CreatePlainTransportRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreatePlainTransportRequestBuilder<()> { - CreatePlainTransportRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); - object_writer.write::<_, _, 4>(&prepared_options); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for CreatePlainTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreatePlainTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreatePlainTransportRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreatePlainTransportRequest::create(builder, &self.transport_id, &self.options) - } - } - - /// Builder for serializing an instance of the [CreatePlainTransportRequest] type. - /// - /// Can be created using the [CreatePlainTransportRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreatePlainTransportRequestBuilder(State); - - impl CreatePlainTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreatePlainTransportRequest#structfield.transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_id( - self, - value: T0, - ) -> CreatePlainTransportRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreatePlainTransportRequestBuilder((value,)) - } - } - - impl CreatePlainTransportRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreatePlainTransportRequest#structfield.options). - #[inline] - #[allow(clippy::type_complexity)] - pub fn options(self, value: T1) -> CreatePlainTransportRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset, - >, - { - let (v0,) = self.0; - CreatePlainTransportRequestBuilder((v0, value)) - } - } - - impl CreatePlainTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreatePlainTransportRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreatePlainTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for CreatePlainTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for CreatePlainTransportRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreatePlainTransportRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreatePlainTransportRequest]. - #[derive(Copy, Clone)] - pub struct CreatePlainTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreatePlainTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreatePlainTransportRequest#structfield.transport_id). - #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreatePlainTransportRequest", "transport_id") - } - - /// Getter for the [`options` field](CreatePlainTransportRequest#structfield.options). - #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { - self.0 - .access_required(1, "CreatePlainTransportRequest", "options") - } - } - - impl<'a> ::core::fmt::Debug for CreatePlainTransportRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreatePlainTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for CreatePlainTransportRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CreatePlainTransportRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreatePlainTransportRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreatePlainTransportRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreatePlainTransportRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreatePlainTransportRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreatePlainTransportRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreatePlainTransportRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreateWebRtcTransportRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CreateWebRtcTransportRequest` in the file `../worker/fbs/router.fbs:33` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreateWebRtcTransportRequest { - /// The field `transport_id` in the table `CreateWebRtcTransportRequest` - pub transport_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreateWebRtcTransportRequest` - pub options: - ::planus::alloc::boxed::Box, - } - - impl CreateWebRtcTransportRequest { - /// Creates a [CreateWebRtcTransportRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreateWebRtcTransportRequestBuilder<()> { - CreateWebRtcTransportRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); - object_writer.write::<_, _, 4>(&prepared_options); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for CreateWebRtcTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreateWebRtcTransportRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateWebRtcTransportRequest::create(builder, &self.transport_id, &self.options) - } - } - - /// Builder for serializing an instance of the [CreateWebRtcTransportRequest] type. - /// - /// Can be created using the [CreateWebRtcTransportRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreateWebRtcTransportRequestBuilder(State); - - impl CreateWebRtcTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreateWebRtcTransportRequest#structfield.transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_id( - self, - value: T0, - ) -> CreateWebRtcTransportRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreateWebRtcTransportRequestBuilder((value,)) - } - } - - impl CreateWebRtcTransportRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateWebRtcTransportRequest#structfield.options). - #[inline] - #[allow(clippy::type_complexity)] - pub fn options(self, value: T1) -> CreateWebRtcTransportRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset, - >, - { - let (v0,) = self.0; - CreateWebRtcTransportRequestBuilder((v0, value)) - } - } - - impl CreateWebRtcTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateWebRtcTransportRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreateWebRtcTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for CreateWebRtcTransportRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreateWebRtcTransportRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreateWebRtcTransportRequest]. - #[derive(Copy, Clone)] - pub struct CreateWebRtcTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreateWebRtcTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreateWebRtcTransportRequest#structfield.transport_id). - #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreateWebRtcTransportRequest", "transport_id") - } - - /// Getter for the [`options` field](CreateWebRtcTransportRequest#structfield.options). - #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { - self.0 - .access_required(1, "CreateWebRtcTransportRequest", "options") - } - } - - impl<'a> ::core::fmt::Debug for CreateWebRtcTransportRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreateWebRtcTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for CreateWebRtcTransportRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CreateWebRtcTransportRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreateWebRtcTransportRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreateWebRtcTransportRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreateWebRtcTransportRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreateWebRtcTransportRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreateWebRtcTransportRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateWebRtcTransportRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreateDirectTransportRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CreateDirectTransportRequest` in the file `../worker/fbs/router.fbs:38` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreateDirectTransportRequest { - /// The field `transport_id` in the table `CreateDirectTransportRequest` - pub transport_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreateDirectTransportRequest` - pub options: - ::planus::alloc::boxed::Box, - } - - impl CreateDirectTransportRequest { - /// Creates a [CreateDirectTransportRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreateDirectTransportRequestBuilder<()> { - CreateDirectTransportRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); - object_writer.write::<_, _, 4>(&prepared_options); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for CreateDirectTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateDirectTransportRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreateDirectTransportRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateDirectTransportRequest::create(builder, &self.transport_id, &self.options) - } - } - - /// Builder for serializing an instance of the [CreateDirectTransportRequest] type. - /// - /// Can be created using the [CreateDirectTransportRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreateDirectTransportRequestBuilder(State); - - impl CreateDirectTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreateDirectTransportRequest#structfield.transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_id( - self, - value: T0, - ) -> CreateDirectTransportRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreateDirectTransportRequestBuilder((value,)) - } - } - - impl CreateDirectTransportRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateDirectTransportRequest#structfield.options). - #[inline] - #[allow(clippy::type_complexity)] - pub fn options(self, value: T1) -> CreateDirectTransportRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset, - >, - { - let (v0,) = self.0; - CreateDirectTransportRequestBuilder((v0, value)) - } - } - - impl CreateDirectTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateDirectTransportRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreateDirectTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for CreateDirectTransportRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for CreateDirectTransportRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreateDirectTransportRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreateDirectTransportRequest]. - #[derive(Copy, Clone)] - pub struct CreateDirectTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreateDirectTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreateDirectTransportRequest#structfield.transport_id). - #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreateDirectTransportRequest", "transport_id") - } - - /// Getter for the [`options` field](CreateDirectTransportRequest#structfield.options). - #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { - self.0 - .access_required(1, "CreateDirectTransportRequest", "options") - } - } - - impl<'a> ::core::fmt::Debug for CreateDirectTransportRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreateDirectTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for CreateDirectTransportRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CreateDirectTransportRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreateDirectTransportRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreateDirectTransportRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreateDirectTransportRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreateDirectTransportRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreateDirectTransportRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateDirectTransportRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreateAudioLevelObserverRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CreateAudioLevelObserverRequest` in the file `../worker/fbs/router.fbs:43` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreateAudioLevelObserverRequest { - /// The field `rtp_observer_id` in the table `CreateAudioLevelObserverRequest` - pub rtp_observer_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreateAudioLevelObserverRequest` - pub options: ::planus::alloc::boxed::Box< - super::audio_level_observer::AudioLevelObserverOptions, - >, - } - - impl CreateAudioLevelObserverRequest { - /// Creates a [CreateAudioLevelObserverRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreateAudioLevelObserverRequestBuilder<()> { - CreateAudioLevelObserverRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_observer_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_rtp_observer_id = field_rtp_observer_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset< - super::audio_level_observer::AudioLevelObserverOptions, - >>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); - object_writer.write::<_, _, 4>(&prepared_options); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for CreateAudioLevelObserverRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateAudioLevelObserverRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CreateAudioLevelObserverRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateAudioLevelObserverRequest::create( - builder, - &self.rtp_observer_id, - &self.options, - ) - } - } - - /// Builder for serializing an instance of the [CreateAudioLevelObserverRequest] type. - /// - /// Can be created using the [CreateAudioLevelObserverRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreateAudioLevelObserverRequestBuilder(State); - - impl CreateAudioLevelObserverRequestBuilder<()> { - /// Setter for the [`rtp_observer_id` field](CreateAudioLevelObserverRequest#structfield.rtp_observer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_observer_id( - self, - value: T0, - ) -> CreateAudioLevelObserverRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreateAudioLevelObserverRequestBuilder((value,)) - } - } - - impl CreateAudioLevelObserverRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateAudioLevelObserverRequest#structfield.options). - #[inline] - #[allow(clippy::type_complexity)] - pub fn options( - self, - value: T1, - ) -> CreateAudioLevelObserverRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset, - >, - { - let (v0,) = self.0; - CreateAudioLevelObserverRequestBuilder((v0, value)) - } - } - - impl CreateAudioLevelObserverRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateAudioLevelObserverRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreateAudioLevelObserverRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for CreateAudioLevelObserverRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for CreateAudioLevelObserverRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreateAudioLevelObserverRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreateAudioLevelObserverRequest]. - #[derive(Copy, Clone)] - pub struct CreateAudioLevelObserverRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreateAudioLevelObserverRequestRef<'a> { - /// Getter for the [`rtp_observer_id` field](CreateAudioLevelObserverRequest#structfield.rtp_observer_id). - #[inline] - pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreateAudioLevelObserverRequest", "rtp_observer_id") - } - - /// Getter for the [`options` field](CreateAudioLevelObserverRequest#structfield.options). - #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { - self.0 - .access_required(1, "CreateAudioLevelObserverRequest", "options") - } - } - - impl<'a> ::core::fmt::Debug for CreateAudioLevelObserverRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreateAudioLevelObserverRequestRef"); - f.field("rtp_observer_id", &self.rtp_observer_id()); - f.field("options", &self.options()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for CreateAudioLevelObserverRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from( - value: CreateAudioLevelObserverRequestRef<'a>, - ) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_observer_id: ::core::convert::TryInto::try_into( - value.rtp_observer_id()?, - )?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreateAudioLevelObserverRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreateAudioLevelObserverRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreateAudioLevelObserverRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreateAudioLevelObserverRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreateAudioLevelObserverRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateAudioLevelObserverRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CreateActiveSpeakerObserverRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CreateActiveSpeakerObserverRequest` in the file `../worker/fbs/router.fbs:48` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CreateActiveSpeakerObserverRequest { - /// The field `rtp_observer_id` in the table `CreateActiveSpeakerObserverRequest` - pub rtp_observer_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreateActiveSpeakerObserverRequest` - pub options: ::planus::alloc::boxed::Box< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - } - - impl CreateActiveSpeakerObserverRequest { - /// Creates a [CreateActiveSpeakerObserverRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CreateActiveSpeakerObserverRequestBuilder<()> { - CreateActiveSpeakerObserverRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_observer_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, - ) -> ::planus::Offset { - let prepared_rtp_observer_id = field_rtp_observer_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); - object_writer.write::<_, _, 4>(&prepared_options); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for CreateActiveSpeakerObserverRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateActiveSpeakerObserverRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset - for CreateActiveSpeakerObserverRequest - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateActiveSpeakerObserverRequest::create( - builder, - &self.rtp_observer_id, - &self.options, - ) - } - } - - /// Builder for serializing an instance of the [CreateActiveSpeakerObserverRequest] type. - /// - /// Can be created using the [CreateActiveSpeakerObserverRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CreateActiveSpeakerObserverRequestBuilder(State); - - impl CreateActiveSpeakerObserverRequestBuilder<()> { - /// Setter for the [`rtp_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.rtp_observer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_observer_id( - self, - value: T0, - ) -> CreateActiveSpeakerObserverRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CreateActiveSpeakerObserverRequestBuilder((value,)) - } - } - - impl CreateActiveSpeakerObserverRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). - #[inline] - #[allow(clippy::type_complexity)] - pub fn options( - self, - value: T1, - ) -> CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, - { - let (v0,) = self.0; - CreateActiveSpeakerObserverRequestBuilder((v0, value)) - } - } - - impl CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateActiveSpeakerObserverRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, - > - ::planus::WriteAs<::planus::Offset> - for CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, - > - ::planus::WriteAsOptional<::planus::Offset> - for CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, - > ::planus::WriteAsOffset - for CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreateActiveSpeakerObserverRequest::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [CreateActiveSpeakerObserverRequest]. - #[derive(Copy, Clone)] - pub struct CreateActiveSpeakerObserverRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CreateActiveSpeakerObserverRequestRef<'a> { - /// Getter for the [`rtp_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.rtp_observer_id). - #[inline] - pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required( - 0, - "CreateActiveSpeakerObserverRequest", - "rtp_observer_id", - ) - } - - /// Getter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). - #[inline] - pub fn options( - &self, - ) -> ::planus::Result< - super::active_speaker_observer::ActiveSpeakerObserverOptionsRef<'a>, - > { - self.0 - .access_required(1, "CreateActiveSpeakerObserverRequest", "options") - } - } - - impl<'a> ::core::fmt::Debug for CreateActiveSpeakerObserverRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CreateActiveSpeakerObserverRequestRef"); - f.field("rtp_observer_id", &self.rtp_observer_id()); - f.field("options", &self.options()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for CreateActiveSpeakerObserverRequest - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from( - value: CreateActiveSpeakerObserverRequestRef<'a>, - ) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_observer_id: ::core::convert::TryInto::try_into( - value.rtp_observer_id()?, - )?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CreateActiveSpeakerObserverRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CreateActiveSpeakerObserverRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CreateActiveSpeakerObserverRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for CreateActiveSpeakerObserverRequest - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CreateActiveSpeakerObserverRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateActiveSpeakerObserverRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseTransportRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CloseTransportRequest` in the file `../worker/fbs/router.fbs:53` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseTransportRequest { - /// The field `transport_id` in the table `CloseTransportRequest` - pub transport_id: ::planus::alloc::string::String, - } - - impl CloseTransportRequest { - /// Creates a [CloseTransportRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseTransportRequestBuilder<()> { - CloseTransportRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseTransportRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for CloseTransportRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseTransportRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseTransportRequest::create(builder, &self.transport_id) - } - } - - /// Builder for serializing an instance of the [CloseTransportRequest] type. - /// - /// Can be created using the [CloseTransportRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseTransportRequestBuilder(State); - - impl CloseTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CloseTransportRequest#structfield.transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn transport_id(self, value: T0) -> CloseTransportRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseTransportRequestBuilder((value,)) - } - } - - impl CloseTransportRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseTransportRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseTransportRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseTransportRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseTransportRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseTransportRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseTransportRequest]. - #[derive(Copy, Clone)] - pub struct CloseTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CloseTransportRequest#structfield.transport_id). - #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseTransportRequest", "transport_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseTransportRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseTransportRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseTransportRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseTransportRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseTransportRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseTransportRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CloseTransportRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseTransportRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseTransportRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `CloseRtpObserverRequest` in the namespace `FBS.Router` - /// - /// Generated from these locations: - /// * Table `CloseRtpObserverRequest` in the file `../worker/fbs/router.fbs:57` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct CloseRtpObserverRequest { - /// The field `rtp_observer_id` in the table `CloseRtpObserverRequest` - pub rtp_observer_id: ::planus::alloc::string::String, - } - - impl CloseRtpObserverRequest { - /// Creates a [CloseRtpObserverRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> CloseRtpObserverRequestBuilder<()> { - CloseRtpObserverRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_observer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_rtp_observer_id = field_rtp_observer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for CloseRtpObserverRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for CloseRtpObserverRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for CloseRtpObserverRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseRtpObserverRequest::create(builder, &self.rtp_observer_id) - } - } - - /// Builder for serializing an instance of the [CloseRtpObserverRequest] type. - /// - /// Can be created using the [CloseRtpObserverRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct CloseRtpObserverRequestBuilder(State); - - impl CloseRtpObserverRequestBuilder<()> { - /// Setter for the [`rtp_observer_id` field](CloseRtpObserverRequest#structfield.rtp_observer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_observer_id(self, value: T0) -> CloseRtpObserverRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - CloseRtpObserverRequestBuilder((value,)) - } - } - - impl CloseRtpObserverRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseRtpObserverRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseRtpObserverRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseRtpObserverRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for CloseRtpObserverRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - CloseRtpObserverRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [CloseRtpObserverRequest]. - #[derive(Copy, Clone)] - pub struct CloseRtpObserverRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> CloseRtpObserverRequestRef<'a> { - /// Getter for the [`rtp_observer_id` field](CloseRtpObserverRequest#structfield.rtp_observer_id). - #[inline] - pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CloseRtpObserverRequest", "rtp_observer_id") - } - } - - impl<'a> ::core::fmt::Debug for CloseRtpObserverRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("CloseRtpObserverRequestRef"); - f.field("rtp_observer_id", &self.rtp_observer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for CloseRtpObserverRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: CloseRtpObserverRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_observer_id: ::core::convert::TryInto::try_into( - value.rtp_observer_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for CloseRtpObserverRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for CloseRtpObserverRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[CloseRtpObserverRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for CloseRtpObserverRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for CloseRtpObserverRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseRtpObserverRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.WebRtcServer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/webRtcServer.fbs` - pub mod web_rtc_server { - /// The table `IpPort` in the namespace `FBS.WebRtcServer` - /// - /// Generated from these locations: - /// * Table `IpPort` in the file `../worker/fbs/webRtcServer.fbs:5` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct IpPort { - /// The field `ip` in the table `IpPort` - pub ip: ::planus::alloc::string::String, - /// The field `port` in the table `IpPort` - pub port: u16, - } - - impl IpPort { - /// Creates a [IpPortBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> IpPortBuilder<()> { - IpPortBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ip: impl ::planus::WriteAs<::planus::Offset>, - field_port: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ip = field_ip.prepare(builder); - let prepared_port = field_port.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_port.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_ip); - if let ::core::option::Option::Some(prepared_port) = prepared_port { - object_writer.write::<_, _, 2>(&prepared_port); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for IpPort { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for IpPort { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for IpPort { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - IpPort::create(builder, &self.ip, self.port) - } - } - - /// Builder for serializing an instance of the [IpPort] type. - /// - /// Can be created using the [IpPort::builder] method. - #[derive(Debug)] - #[must_use] - pub struct IpPortBuilder(State); - - impl IpPortBuilder<()> { - /// Setter for the [`ip` field](IpPort#structfield.ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ip(self, value: T0) -> IpPortBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - IpPortBuilder((value,)) - } - } - - impl IpPortBuilder<(T0,)> { - /// Setter for the [`port` field](IpPort#structfield.port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn port(self, value: T1) -> IpPortBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - IpPortBuilder((v0, value)) - } - - /// Sets the [`port` field](IpPort#structfield.port) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn port_as_default(self) -> IpPortBuilder<(T0, ::planus::DefaultValue)> { - self.port(::planus::DefaultValue) - } - } - - impl IpPortBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IpPort]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> for IpPortBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> for IpPortBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for IpPortBuilder<(T0, T1)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - IpPort::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [IpPort]. - #[derive(Copy, Clone)] - pub struct IpPortRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> IpPortRef<'a> { - /// Getter for the [`ip` field](IpPort#structfield.ip). - #[inline] - pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "IpPort", "ip") - } - - /// Getter for the [`port` field](IpPort#structfield.port). - #[inline] - pub fn port(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "IpPort", "port")?.unwrap_or(0)) - } - } - - impl<'a> ::core::fmt::Debug for IpPortRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("IpPortRef"); - f.field("ip", &self.ip()); - f.field("port", &self.port()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for IpPort { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: IpPortRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ip: ::core::convert::TryInto::try_into(value.ip()?)?, - port: ::core::convert::TryInto::try_into(value.port()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for IpPortRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for IpPortRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[IpPortRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for IpPort { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for IpPortRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[IpPortRef]", "read_as_root", 0) - }) - } - } - - /// The table `IceUserNameFragment` in the namespace `FBS.WebRtcServer` - /// - /// Generated from these locations: - /// * Table `IceUserNameFragment` in the file `../worker/fbs/webRtcServer.fbs:10` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct IceUserNameFragment { - /// The field `local_ice_username_fragment` in the table `IceUserNameFragment` - pub local_ice_username_fragment: ::planus::alloc::string::String, - /// The field `web_rtc_transport_id` in the table `IceUserNameFragment` - pub web_rtc_transport_id: ::planus::alloc::string::String, - } - - impl IceUserNameFragment { - /// Creates a [IceUserNameFragmentBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> IceUserNameFragmentBuilder<()> { - IceUserNameFragmentBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_local_ice_username_fragment: impl ::planus::WriteAs<::planus::Offset>, - field_web_rtc_transport_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_local_ice_username_fragment = - field_local_ice_username_fragment.prepare(builder); - let prepared_web_rtc_transport_id = field_web_rtc_transport_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_local_ice_username_fragment); - object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for IceUserNameFragment { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for IceUserNameFragment { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for IceUserNameFragment { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceUserNameFragment::create( - builder, - &self.local_ice_username_fragment, - &self.web_rtc_transport_id, - ) - } - } - - /// Builder for serializing an instance of the [IceUserNameFragment] type. - /// - /// Can be created using the [IceUserNameFragment::builder] method. - #[derive(Debug)] - #[must_use] - pub struct IceUserNameFragmentBuilder(State); - - impl IceUserNameFragmentBuilder<()> { - /// Setter for the [`local_ice_username_fragment` field](IceUserNameFragment#structfield.local_ice_username_fragment). - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragment( - self, - value: T0, - ) -> IceUserNameFragmentBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - IceUserNameFragmentBuilder((value,)) - } - } - - impl IceUserNameFragmentBuilder<(T0,)> { - /// Setter for the [`web_rtc_transport_id` field](IceUserNameFragment#structfield.web_rtc_transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_transport_id( - self, - value: T1, - ) -> IceUserNameFragmentBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - IceUserNameFragmentBuilder((v0, value)) - } - } - - impl IceUserNameFragmentBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IceUserNameFragment]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for IceUserNameFragmentBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for IceUserNameFragmentBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset - for IceUserNameFragmentBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - IceUserNameFragment::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [IceUserNameFragment]. - #[derive(Copy, Clone)] - pub struct IceUserNameFragmentRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> IceUserNameFragmentRef<'a> { - /// Getter for the [`local_ice_username_fragment` field](IceUserNameFragment#structfield.local_ice_username_fragment). - #[inline] - pub fn local_ice_username_fragment( - &self, - ) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "IceUserNameFragment", "local_ice_username_fragment") - } - - /// Getter for the [`web_rtc_transport_id` field](IceUserNameFragment#structfield.web_rtc_transport_id). - #[inline] - pub fn web_rtc_transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(1, "IceUserNameFragment", "web_rtc_transport_id") - } - } - - impl<'a> ::core::fmt::Debug for IceUserNameFragmentRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("IceUserNameFragmentRef"); - f.field( - "local_ice_username_fragment", - &self.local_ice_username_fragment(), - ); - f.field("web_rtc_transport_id", &self.web_rtc_transport_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for IceUserNameFragment { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: IceUserNameFragmentRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - local_ice_username_fragment: ::core::convert::TryInto::try_into( - value.local_ice_username_fragment()?, - )?, - web_rtc_transport_id: ::core::convert::TryInto::try_into( - value.web_rtc_transport_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for IceUserNameFragmentRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for IceUserNameFragmentRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[IceUserNameFragmentRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for IceUserNameFragment { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for IceUserNameFragmentRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[IceUserNameFragmentRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `TupleHash` in the namespace `FBS.WebRtcServer` - /// - /// Generated from these locations: - /// * Table `TupleHash` in the file `../worker/fbs/webRtcServer.fbs:15` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct TupleHash { - /// The field `tuple_hash` in the table `TupleHash` - pub tuple_hash: u64, - /// The field `web_rtc_transport_id` in the table `TupleHash` - pub web_rtc_transport_id: ::planus::alloc::string::String, - } - - impl TupleHash { - /// Creates a [TupleHashBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TupleHashBuilder<()> { - TupleHashBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_tuple_hash: impl ::planus::WriteAsDefault, - field_web_rtc_transport_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_tuple_hash = field_tuple_hash.prepare(builder, &0); - let prepared_web_rtc_transport_id = field_web_rtc_transport_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_tuple_hash.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_tuple_hash) = - prepared_tuple_hash - { - object_writer.write::<_, _, 8>(&prepared_tuple_hash); - } - object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for TupleHash { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for TupleHash { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for TupleHash { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - TupleHash::create(builder, self.tuple_hash, &self.web_rtc_transport_id) - } - } - - /// Builder for serializing an instance of the [TupleHash] type. - /// - /// Can be created using the [TupleHash::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TupleHashBuilder(State); - - impl TupleHashBuilder<()> { - /// Setter for the [`tuple_hash` field](TupleHash#structfield.tuple_hash). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple_hash(self, value: T0) -> TupleHashBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - TupleHashBuilder((value,)) - } - - /// Sets the [`tuple_hash` field](TupleHash#structfield.tuple_hash) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple_hash_as_default(self) -> TupleHashBuilder<(::planus::DefaultValue,)> { - self.tuple_hash(::planus::DefaultValue) - } - } - - impl TupleHashBuilder<(T0,)> { - /// Setter for the [`web_rtc_transport_id` field](TupleHash#structfield.web_rtc_transport_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_transport_id(self, value: T1) -> TupleHashBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - TupleHashBuilder((v0, value)) - } - } - - impl TupleHashBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TupleHash]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> for TupleHashBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for TupleHashBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for TupleHashBuilder<(T0, T1)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - TupleHash::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [TupleHash]. - #[derive(Copy, Clone)] - pub struct TupleHashRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TupleHashRef<'a> { - /// Getter for the [`tuple_hash` field](TupleHash#structfield.tuple_hash). - #[inline] - pub fn tuple_hash(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "TupleHash", "tuple_hash")?.unwrap_or(0), - ) - } - - /// Getter for the [`web_rtc_transport_id` field](TupleHash#structfield.web_rtc_transport_id). - #[inline] - pub fn web_rtc_transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(1, "TupleHash", "web_rtc_transport_id") - } - } - - impl<'a> ::core::fmt::Debug for TupleHashRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("TupleHashRef"); - f.field("tuple_hash", &self.tuple_hash()); - f.field("web_rtc_transport_id", &self.web_rtc_transport_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for TupleHash { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: TupleHashRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - tuple_hash: ::core::convert::TryInto::try_into(value.tuple_hash()?)?, - web_rtc_transport_id: ::core::convert::TryInto::try_into( - value.web_rtc_transport_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for TupleHashRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for TupleHashRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[TupleHashRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for TupleHash { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for TupleHashRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[TupleHashRef]", "read_as_root", 0) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.WebRtcServer` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/webRtcServer.fbs:20` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `id` in the table `DumpResponse` - pub id: ::planus::alloc::string::String, - /// The field `udp_sockets` in the table `DumpResponse` - pub udp_sockets: ::planus::alloc::vec::Vec, - /// The field `tcp_servers` in the table `DumpResponse` - pub tcp_servers: ::planus::alloc::vec::Vec, - /// The field `web_rtc_transport_ids` in the table `DumpResponse` - pub web_rtc_transport_ids: - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `local_ice_username_fragments` in the table `DumpResponse` - pub local_ice_username_fragments: - ::planus::alloc::vec::Vec, - /// The field `tuple_hashes` in the table `DumpResponse` - pub tuple_hashes: ::planus::alloc::vec::Vec, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_udp_sockets: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_tcp_servers: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_web_rtc_transport_ids: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_local_ice_username_fragments: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_tuple_hashes: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_udp_sockets = field_udp_sockets.prepare(builder); - let prepared_tcp_servers = field_tcp_servers.prepare(builder); - let prepared_web_rtc_transport_ids = - field_web_rtc_transport_ids.prepare(builder); - let prepared_local_ice_username_fragments = - field_local_ice_username_fragments.prepare(builder); - let prepared_tuple_hashes = field_tuple_hashes.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(1); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(2); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(3); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(4); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(5); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_udp_sockets); - object_writer.write::<_, _, 4>(&prepared_tcp_servers); - object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_ids); - object_writer.write::<_, _, 4>(&prepared_local_ice_username_fragments); - object_writer.write::<_, _, 4>(&prepared_tuple_hashes); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.id, - &self.udp_sockets, - &self.tcp_servers, - &self.web_rtc_transport_ids, - &self.local_ice_username_fragments, - &self.tuple_hashes, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`udp_sockets` field](DumpResponse#structfield.udp_sockets). - #[inline] - #[allow(clippy::type_complexity)] - pub fn udp_sockets(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`tcp_servers` field](DumpResponse#structfield.tcp_servers). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tcp_servers(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`web_rtc_transport_ids` field](DumpResponse#structfield.web_rtc_transport_ids). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_transport_ids( - self, - value: T3, - ) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`local_ice_username_fragments` field](DumpResponse#structfield.local_ice_username_fragments). - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragments( - self, - value: T4, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`tuple_hashes` field](DumpResponse#structfield.tuple_hashes). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple_hashes( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`id` field](DumpResponse#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "DumpResponse", "id") - } - - /// Getter for the [`udp_sockets` field](DumpResponse#structfield.udp_sockets). - #[inline] - pub fn udp_sockets( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(1, "DumpResponse", "udp_sockets") - } - - /// Getter for the [`tcp_servers` field](DumpResponse#structfield.tcp_servers). - #[inline] - pub fn tcp_servers( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(2, "DumpResponse", "tcp_servers") - } - - /// Getter for the [`web_rtc_transport_ids` field](DumpResponse#structfield.web_rtc_transport_ids). - #[inline] - pub fn web_rtc_transport_ids( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0 - .access_required(3, "DumpResponse", "web_rtc_transport_ids") - } - - /// Getter for the [`local_ice_username_fragments` field](DumpResponse#structfield.local_ice_username_fragments). - #[inline] - pub fn local_ice_username_fragments( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(4, "DumpResponse", "local_ice_username_fragments") - } - - /// Getter for the [`tuple_hashes` field](DumpResponse#structfield.tuple_hashes). - #[inline] - pub fn tuple_hashes( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(5, "DumpResponse", "tuple_hashes") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("id", &self.id()); - f.field("udp_sockets", &self.udp_sockets()); - f.field("tcp_servers", &self.tcp_servers()); - f.field("web_rtc_transport_ids", &self.web_rtc_transport_ids()); - f.field( - "local_ice_username_fragments", - &self.local_ice_username_fragments(), - ); - f.field("tuple_hashes", &self.tuple_hashes()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - udp_sockets: value.udp_sockets()?.to_vec_result()?, - tcp_servers: value.tcp_servers()?.to_vec_result()?, - web_rtc_transport_ids: value.web_rtc_transport_ids()?.to_vec_result()?, - local_ice_username_fragments: value - .local_ice_username_fragments()? - .to_vec_result()?, - tuple_hashes: value.tuple_hashes()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/producer.fbs` - pub mod producer { - /// The enum `TraceEventType` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/producer.fbs:8` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceEventType { - /// The variant `KEYFRAME` in the enum `TraceEventType` - Keyframe = 0, - - /// The variant `FIR` in the enum `TraceEventType` - Fir = 1, - - /// The variant `NACK` in the enum `TraceEventType` - Nack = 2, - - /// The variant `PLI` in the enum `TraceEventType` - Pli = 3, - - /// The variant `RTP` in the enum `TraceEventType` - Rtp = 4, - } - - impl TraceEventType { - /// Array containing all valid variants of TraceEventType - pub const ENUM_VALUES: [Self; 5] = - [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; - } - - impl ::core::convert::TryFrom for TraceEventType { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(TraceEventType::Keyframe), - 1 => ::core::result::Result::Ok(TraceEventType::Fir), - 2 => ::core::result::Result::Ok(TraceEventType::Nack), - 3 => ::core::result::Result::Ok(TraceEventType::Pli), - 4 => ::core::result::Result::Ok(TraceEventType::Rtp), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceEventType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceEventType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceEventType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceEventType { - *self - } - } - - impl ::planus::WriteAsDefault for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceEventType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceEventType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for TraceEventType { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for TraceEventType { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "TraceEventType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for TraceEventType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `EnableTraceEventRequest` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:16` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct EnableTraceEventRequest { - /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec, - } - - impl EnableTraceEventRequest { - /// Creates a [EnableTraceEventRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> EnableTraceEventRequestBuilder<()> { - EnableTraceEventRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - ) -> ::planus::Offset { - let prepared_events = field_events.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_events); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequest - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for EnableTraceEventRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - EnableTraceEventRequest::create(builder, &self.events) - } - } - - /// Builder for serializing an instance of the [EnableTraceEventRequest] type. - /// - /// Can be created using the [EnableTraceEventRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct EnableTraceEventRequestBuilder(State); - - impl EnableTraceEventRequestBuilder<()> { - /// Setter for the [`events` field](EnableTraceEventRequest#structfield.events). - #[inline] - #[allow(clippy::type_complexity)] - pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - { - EnableTraceEventRequestBuilder((value,)) - } - } - - impl EnableTraceEventRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [EnableTraceEventRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for EnableTraceEventRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - EnableTraceEventRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [EnableTraceEventRequest]. - #[derive(Copy, Clone)] - pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> EnableTraceEventRequestRef<'a> { - /// Getter for the [`events` field](EnableTraceEventRequest#structfield.events). - #[inline] - pub fn events( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::core::result::Result< - self::TraceEventType, - ::planus::errors::UnknownEnumTag, - >, - >, - > { - self.0 - .access_required(0, "EnableTraceEventRequest", "events") - } - } - - impl<'a> ::core::fmt::Debug for EnableTraceEventRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("EnableTraceEventRequestRef"); - f.field("events", &self.events()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for EnableTraceEventRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: EnableTraceEventRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - events: value.events()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for EnableTraceEventRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for EnableTraceEventRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for EnableTraceEventRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:20` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `id` in the table `DumpResponse` - pub id: ::planus::alloc::string::String, - /// The field `kind` in the table `DumpResponse` - pub kind: super::rtp_parameters::MediaKind, - /// The field `type` in the table `DumpResponse` - pub type_: super::rtp_parameters::Type, - /// The field `rtp_parameters` in the table `DumpResponse` - pub rtp_parameters: - ::planus::alloc::boxed::Box, - /// The field `rtp_mapping` in the table `DumpResponse` - pub rtp_mapping: ::planus::alloc::boxed::Box, - /// The field `rtp_streams` in the table `DumpResponse` - pub rtp_streams: ::planus::alloc::vec::Vec, - /// The field `trace_event_types` in the table `DumpResponse` - pub trace_event_types: ::planus::alloc::vec::Vec, - /// The field `paused` in the table `DumpResponse` - pub paused: bool, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_kind: impl ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - field_type_: impl ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - field_rtp_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtp_mapping: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtp_streams: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[self::TraceEventType]>, - >, - field_paused: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::Audio); - let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); - let prepared_rtp_parameters = field_rtp_parameters.prepare(builder); - let prepared_rtp_mapping = field_rtp_mapping.prepare(builder); - let prepared_rtp_streams = field_rtp_streams.prepare(builder); - let prepared_trace_event_types = field_trace_event_types.prepare(builder); - let prepared_paused = field_paused.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer - .write_entry::<::planus::Offset>(3); - table_writer - .write_entry::<::planus::Offset>(4); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); - table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(6); - if prepared_kind.is_some() { - table_writer.write_entry::(1); - } - if prepared_type_.is_some() { - table_writer.write_entry::(2); - } - if prepared_paused.is_some() { - table_writer.write_entry::(7); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_rtp_parameters); - object_writer.write::<_, _, 4>(&prepared_rtp_mapping); - object_writer.write::<_, _, 4>(&prepared_rtp_streams); - object_writer.write::<_, _, 4>(&prepared_trace_event_types); - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - object_writer.write::<_, _, 1>(&prepared_kind); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.id, - self.kind, - self.type_, - &self.rtp_parameters, - &self.rtp_mapping, - &self.rtp_streams, - &self.trace_event_types, - self.paused, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`kind` field](DumpResponse#structfield.kind). - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - - /// Sets the [`kind` field](DumpResponse#structfield.kind) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn kind_as_default(self) -> DumpResponseBuilder<(T0, ::planus::DefaultValue)> { - self.kind(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - - /// Sets the [`type` field](DumpResponse#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.type_(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`rtp_parameters` field](DumpResponse#structfield.rtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_parameters(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtp_mapping` field](DumpResponse#structfield.rtp_mapping). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_mapping(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`rtp_streams` field](DumpResponse#structfield.rtp_streams). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_streams( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`trace_event_types` field](DumpResponse#structfield.trace_event_types). - #[inline] - #[allow(clippy::type_complexity)] - pub fn trace_event_types( - self, - value: T6, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`paused` field](DumpResponse#structfield.paused). - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused( - self, - value: T7, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, - T2: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`id` field](DumpResponse#structfield.id). - #[inline] - pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "DumpResponse", "id") - } - - /// Getter for the [`kind` field](DumpResponse#structfield.kind). - #[inline] - pub fn kind(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "DumpResponse", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::Audio), - ) - } - - /// Getter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "DumpResponse", "type_")? - .unwrap_or(super::rtp_parameters::Type::Simple), - ) - } - - /// Getter for the [`rtp_parameters` field](DumpResponse#structfield.rtp_parameters). - #[inline] - pub fn rtp_parameters( - &self, - ) -> ::planus::Result> { - self.0.access_required(3, "DumpResponse", "rtp_parameters") - } - - /// Getter for the [`rtp_mapping` field](DumpResponse#structfield.rtp_mapping). - #[inline] - pub fn rtp_mapping( - &self, - ) -> ::planus::Result> { - self.0.access_required(4, "DumpResponse", "rtp_mapping") - } - - /// Getter for the [`rtp_streams` field](DumpResponse#structfield.rtp_streams). - #[inline] - pub fn rtp_streams( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(5, "DumpResponse", "rtp_streams") - } - - /// Getter for the [`trace_event_types` field](DumpResponse#structfield.trace_event_types). - #[inline] - pub fn trace_event_types( - &self, - ) -> ::planus::Result< - ::planus::Vector< - 'a, - ::core::result::Result< - self::TraceEventType, - ::planus::errors::UnknownEnumTag, - >, - >, - > { - self.0 - .access_required(6, "DumpResponse", "trace_event_types") - } - - /// Getter for the [`paused` field](DumpResponse#structfield.paused). - #[inline] - pub fn paused(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(7, "DumpResponse", "paused")?.unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("id", &self.id()); - f.field("kind", &self.kind()); - f.field("type_", &self.type_()); - f.field("rtp_parameters", &self.rtp_parameters()); - f.field("rtp_mapping", &self.rtp_mapping()); - f.field("rtp_streams", &self.rtp_streams()); - f.field("trace_event_types", &self.trace_event_types()); - f.field("paused", &self.paused()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - id: ::core::convert::TryInto::try_into(value.id()?)?, - kind: ::core::convert::TryInto::try_into(value.kind()?)?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - rtp_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_parameters()?)?, - ), - rtp_mapping: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_mapping()?)?, - ), - rtp_streams: value.rtp_streams()?.to_vec_result()?, - trace_event_types: value.trace_event_types()?.to_vec_result()?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:31` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `stats` in the table `GetStatsResponse` - pub stats: ::planus::alloc::vec::Vec, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_stats: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_stats = field_stats.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_stats); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create(builder, &self.stats) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`stats` field](GetStatsResponse#structfield.stats). - #[inline] - #[allow(clippy::type_complexity)] - pub fn stats(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - GetStatsResponseBuilder((value,)) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - GetStatsResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`stats` field](GetStatsResponse#structfield.stats). - #[inline] - pub fn stats( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "GetStatsResponse", "stats") - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("stats", &self.stats()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - stats: value.stats()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `SendNotification` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:35` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct SendNotification { - /// The field `data` in the table `SendNotification` - pub data: ::planus::alloc::vec::Vec, - } - - impl SendNotification { - /// Creates a [SendNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SendNotificationBuilder<()> { - SendNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::planus::Offset { - let prepared_data = field_data.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u8]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SendNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for SendNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for SendNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendNotification::create(builder, &self.data) - } - } - - /// Builder for serializing an instance of the [SendNotification] type. - /// - /// Can be created using the [SendNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SendNotificationBuilder(State); - - impl SendNotificationBuilder<()> { - /// Setter for the [`data` field](SendNotification#structfield.data). - #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> SendNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - SendNotificationBuilder((value,)) - } - } - - impl SendNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for SendNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SendNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for SendNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SendNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [SendNotification]. - #[derive(Copy, Clone)] - pub struct SendNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SendNotificationRef<'a> { - /// Getter for the [`data` field](SendNotification#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "SendNotification", "data") - } - } - - impl<'a> ::core::fmt::Debug for SendNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SendNotificationRef"); - f.field("data", &self.data()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SendNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SendNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - data: value.data()?.to_vec(), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for SendNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[SendNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SendNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for SendNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[SendNotificationRef]", "read_as_root", 0) - }) - } - } - - /// The table `Score` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `Score` in the file `../worker/fbs/producer.fbs:41` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Score { - /// The field `encoding_idx` in the table `Score` - pub encoding_idx: u32, - /// The field `ssrc` in the table `Score` - pub ssrc: u32, - /// The field `rid` in the table `Score` - pub rid: ::core::option::Option<::planus::alloc::string::String>, - /// The field `score` in the table `Score` - pub score: u8, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Score { - fn default() -> Self { - Self { - encoding_idx: 0, - ssrc: 0, - rid: ::core::default::Default::default(), - score: 0, - } - } - } - - impl Score { - /// Creates a [ScoreBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ScoreBuilder<()> { - ScoreBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_encoding_idx: impl ::planus::WriteAsDefault, - field_ssrc: impl ::planus::WriteAsDefault, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_score: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_encoding_idx = field_encoding_idx.prepare(builder, &0); - let prepared_ssrc = field_ssrc.prepare(builder, &0); - let prepared_rid = field_rid.prepare(builder); - let prepared_score = field_score.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_encoding_idx.is_some() { - table_writer.write_entry::(0); - } - if prepared_ssrc.is_some() { - table_writer.write_entry::(1); - } - if prepared_rid.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_score.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_encoding_idx) = - prepared_encoding_idx - { - object_writer.write::<_, _, 4>(&prepared_encoding_idx); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - object_writer.write::<_, _, 4>(&prepared_rid); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - object_writer.write::<_, _, 1>(&prepared_score); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Score { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Score { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Score { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Score::create(builder, self.encoding_idx, self.ssrc, &self.rid, self.score) - } - } - - /// Builder for serializing an instance of the [Score] type. - /// - /// Can be created using the [Score::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ScoreBuilder(State); - - impl ScoreBuilder<()> { - /// Setter for the [`encoding_idx` field](Score#structfield.encoding_idx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn encoding_idx(self, value: T0) -> ScoreBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ScoreBuilder((value,)) - } - - /// Sets the [`encoding_idx` field](Score#structfield.encoding_idx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn encoding_idx_as_default(self) -> ScoreBuilder<(::planus::DefaultValue,)> { - self.encoding_idx(::planus::DefaultValue) - } - } - - impl ScoreBuilder<(T0,)> { - /// Setter for the [`ssrc` field](Score#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T1) -> ScoreBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - ScoreBuilder((v0, value)) - } - - /// Sets the [`ssrc` field](Score#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> ScoreBuilder<(T0, ::planus::DefaultValue)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl ScoreBuilder<(T0, T1)> { - /// Setter for the [`rid` field](Score#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid(self, value: T2) -> ScoreBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0, v1) = self.0; - ScoreBuilder((v0, v1, value)) - } - - /// Sets the [`rid` field](Score#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> ScoreBuilder<(T0, T1, ())> { - self.rid(()) - } - } - - impl ScoreBuilder<(T0, T1, T2)> { - /// Setter for the [`score` field](Score#structfield.score). - #[inline] - #[allow(clippy::type_complexity)] - pub fn score(self, value: T3) -> ScoreBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - ScoreBuilder((v0, v1, v2, value)) - } - - /// Sets the [`score` field](Score#structfield.score) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn score_as_default( - self, - ) -> ScoreBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.score(::planus::DefaultValue) - } - } - - impl ScoreBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Score]. - #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> for ScoreBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ScoreBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for ScoreBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - Score::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [Score]. - #[derive(Copy, Clone)] - pub struct ScoreRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ScoreRef<'a> { - /// Getter for the [`encoding_idx` field](Score#structfield.encoding_idx). - #[inline] - pub fn encoding_idx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "Score", "encoding_idx")?.unwrap_or(0), - ) - } - - /// Getter for the [`ssrc` field](Score#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Score", "ssrc")?.unwrap_or(0)) - } - - /// Getter for the [`rid` field](Score#structfield.rid). - #[inline] - pub fn rid( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(2, "Score", "rid") - } - - /// Getter for the [`score` field](Score#structfield.score). - #[inline] - pub fn score(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(3, "Score", "score")?.unwrap_or(0)) - } - } - - impl<'a> ::core::fmt::Debug for ScoreRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ScoreRef"); - f.field("encoding_idx", &self.encoding_idx()); - f.field("ssrc", &self.ssrc()); - if let ::core::option::Option::Some(field_rid) = self.rid().transpose() { - f.field("rid", &field_rid); - } - f.field("score", &self.score()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Score { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ScoreRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - encoding_idx: ::core::convert::TryInto::try_into(value.encoding_idx()?)?, - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - rid: if let ::core::option::Option::Some(rid) = value.rid()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(rid)?) - } else { - ::core::option::Option::None - }, - score: ::core::convert::TryInto::try_into(value.score()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ScoreRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ScoreRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ScoreRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Score { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ScoreRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ScoreRef]", "read_as_root", 0) - }) - } - } - - /// The table `ScoreNotification` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:48` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ScoreNotification { - /// The field `scores` in the table `ScoreNotification` - pub scores: ::planus::alloc::vec::Vec, - } - - impl ScoreNotification { - /// Creates a [ScoreNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ScoreNotificationBuilder<()> { - ScoreNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_scores: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_scores = field_scores.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_scores); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ScoreNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ScoreNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ScoreNotification::create(builder, &self.scores) - } - } - - /// Builder for serializing an instance of the [ScoreNotification] type. - /// - /// Can be created using the [ScoreNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ScoreNotificationBuilder(State); - - impl ScoreNotificationBuilder<()> { - /// Setter for the [`scores` field](ScoreNotification#structfield.scores). - #[inline] - #[allow(clippy::type_complexity)] - pub fn scores(self, value: T0) -> ScoreNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - ScoreNotificationBuilder((value,)) - } - } - - impl ScoreNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ScoreNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl]>>> - ::planus::WriteAs<::planus::Offset> - for ScoreNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl]>>> - ::planus::WriteAsOptional<::planus::Offset> - for ScoreNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl]>>> - ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ScoreNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [ScoreNotification]. - #[derive(Copy, Clone)] - pub struct ScoreNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ScoreNotificationRef<'a> { - /// Getter for the [`scores` field](ScoreNotification#structfield.scores). - #[inline] - pub fn scores( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(0, "ScoreNotification", "scores") - } - } - - impl<'a> ::core::fmt::Debug for ScoreNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ScoreNotificationRef"); - f.field("scores", &self.scores()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ScoreNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ScoreNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - scores: value.scores()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ScoreNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ScoreNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ScoreNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ScoreNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ScoreNotificationRef]", "read_as_root", 0) - }) - } - } - - /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:52` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct VideoOrientationChangeNotification { - /// The field `camera` in the table `VideoOrientationChangeNotification` - pub camera: bool, - /// The field `flip` in the table `VideoOrientationChangeNotification` - pub flip: bool, - /// The field `rotation` in the table `VideoOrientationChangeNotification` - pub rotation: u16, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for VideoOrientationChangeNotification { - fn default() -> Self { - Self { - camera: false, - flip: false, - rotation: 0, - } - } - } - - impl VideoOrientationChangeNotification { - /// Creates a [VideoOrientationChangeNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> VideoOrientationChangeNotificationBuilder<()> { - VideoOrientationChangeNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_camera: impl ::planus::WriteAsDefault, - field_flip: impl ::planus::WriteAsDefault, - field_rotation: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_camera = field_camera.prepare(builder, &false); - let prepared_flip = field_flip.prepare(builder, &false); - let prepared_rotation = field_rotation.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - if prepared_rotation.is_some() { - table_writer.write_entry::(2); - } - if prepared_camera.is_some() { - table_writer.write_entry::(0); - } - if prepared_flip.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_rotation) = - prepared_rotation - { - object_writer.write::<_, _, 2>(&prepared_rotation); - } - if let ::core::option::Option::Some(prepared_camera) = prepared_camera { - object_writer.write::<_, _, 1>(&prepared_camera); - } - if let ::core::option::Option::Some(prepared_flip) = prepared_flip { - object_writer.write::<_, _, 1>(&prepared_flip); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for VideoOrientationChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for VideoOrientationChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset - for VideoOrientationChangeNotification - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - VideoOrientationChangeNotification::create( - builder, - self.camera, - self.flip, - self.rotation, - ) - } - } - - /// Builder for serializing an instance of the [VideoOrientationChangeNotification] type. - /// - /// Can be created using the [VideoOrientationChangeNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct VideoOrientationChangeNotificationBuilder(State); - - impl VideoOrientationChangeNotificationBuilder<()> { - /// Setter for the [`camera` field](VideoOrientationChangeNotification#structfield.camera). - #[inline] - #[allow(clippy::type_complexity)] - pub fn camera( - self, - value: T0, - ) -> VideoOrientationChangeNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - VideoOrientationChangeNotificationBuilder((value,)) - } - - /// Sets the [`camera` field](VideoOrientationChangeNotification#structfield.camera) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn camera_as_default( - self, - ) -> VideoOrientationChangeNotificationBuilder<(::planus::DefaultValue,)> - { - self.camera(::planus::DefaultValue) - } - } - - impl VideoOrientationChangeNotificationBuilder<(T0,)> { - /// Setter for the [`flip` field](VideoOrientationChangeNotification#structfield.flip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn flip( - self, - value: T1, - ) -> VideoOrientationChangeNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - VideoOrientationChangeNotificationBuilder((v0, value)) - } - - /// Sets the [`flip` field](VideoOrientationChangeNotification#structfield.flip) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn flip_as_default( - self, - ) -> VideoOrientationChangeNotificationBuilder<(T0, ::planus::DefaultValue)> - { - self.flip(::planus::DefaultValue) - } - } - - impl VideoOrientationChangeNotificationBuilder<(T0, T1)> { - /// Setter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rotation( - self, - value: T2, - ) -> VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - VideoOrientationChangeNotificationBuilder((v0, v1, value)) - } - - /// Sets the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rotation_as_default( - self, - ) -> VideoOrientationChangeNotificationBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.rotation(::planus::DefaultValue) - } - } - - impl VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [VideoOrientationChangeNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - > - ::planus::WriteAs<::planus::Offset> - for VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - > - ::planus::WriteAsOptional<::planus::Offset> - for VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - VideoOrientationChangeNotification::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [VideoOrientationChangeNotification]. - #[derive(Copy, Clone)] - pub struct VideoOrientationChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> VideoOrientationChangeNotificationRef<'a> { - /// Getter for the [`camera` field](VideoOrientationChangeNotification#structfield.camera). - #[inline] - pub fn camera(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "VideoOrientationChangeNotification", "camera")? - .unwrap_or(false), - ) - } - - /// Getter for the [`flip` field](VideoOrientationChangeNotification#structfield.flip). - #[inline] - pub fn flip(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "VideoOrientationChangeNotification", "flip")? - .unwrap_or(false), - ) - } - - /// Getter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). - #[inline] - pub fn rotation(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "VideoOrientationChangeNotification", "rotation")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for VideoOrientationChangeNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("VideoOrientationChangeNotificationRef"); - f.field("camera", &self.camera()); - f.field("flip", &self.flip()); - f.field("rotation", &self.rotation()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for VideoOrientationChangeNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from( - value: VideoOrientationChangeNotificationRef<'a>, - ) -> ::planus::Result { - ::core::result::Result::Ok(Self { - camera: ::core::convert::TryInto::try_into(value.camera()?)?, - flip: ::core::convert::TryInto::try_into(value.flip()?)?, - rotation: ::core::convert::TryInto::try_into(value.rotation()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for VideoOrientationChangeNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for VideoOrientationChangeNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[VideoOrientationChangeNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for VideoOrientationChangeNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for VideoOrientationChangeNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[VideoOrientationChangeNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The union `TraceInfo` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:58` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub enum TraceInfo { - /// The variant of type `KeyFrameTraceInfo` in the union `TraceInfo` - KeyFrameTraceInfo(::planus::alloc::boxed::Box), - - /// The variant of type `FirTraceInfo` in the union `TraceInfo` - FirTraceInfo(::planus::alloc::boxed::Box), - - /// The variant of type `PliTraceInfo` in the union `TraceInfo` - PliTraceInfo(::planus::alloc::boxed::Box), - - /// The variant of type `RtpTraceInfo` in the union `TraceInfo` - RtpTraceInfo(::planus::alloc::boxed::Box), - } - - impl TraceInfo { - /// Creates a [TraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceInfoBuilder<::planus::Uninitialized> { - TraceInfoBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_key_frame_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_fir_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pli_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtp_trace_info( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for TraceInfo { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::KeyFrameTraceInfo(value) => { - Self::create_key_frame_trace_info(builder, value) - } - Self::FirTraceInfo(value) => Self::create_fir_trace_info(builder, value), - Self::PliTraceInfo(value) => Self::create_pli_trace_info(builder, value), - Self::RtpTraceInfo(value) => Self::create_rtp_trace_info(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [TraceInfo] type. - /// - /// Can be created using the [TraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TraceInfoBuilder(T); - - impl TraceInfoBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`KeyFrameTraceInfo` variant](TraceInfo#variant.KeyFrameTraceInfo). - #[inline] - pub fn key_frame_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`FirTraceInfo` variant](TraceInfo#variant.FirTraceInfo). - #[inline] - pub fn fir_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PliTraceInfo` variant](TraceInfo#variant.PliTraceInfo). - #[inline] - pub fn pli_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtpTraceInfo` variant](TraceInfo#variant.RtpTraceInfo). - #[inline] - pub fn rtp_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - TraceInfoBuilder(::planus::Initialized(value)) - } - } - - impl TraceInfoBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [TraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [TraceInfo]. - #[derive(Copy, Clone, Debug)] - pub enum TraceInfoRef<'a> { - KeyFrameTraceInfo(self::KeyFrameTraceInfoRef<'a>), - FirTraceInfo(self::FirTraceInfoRef<'a>), - PliTraceInfo(self::PliTraceInfoRef<'a>), - RtpTraceInfo(self::RtpTraceInfoRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for TraceInfo { - type Error = ::planus::Error; - - fn try_from(value: TraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - TraceInfoRef::KeyFrameTraceInfo(value) => { - Self::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - TraceInfoRef::FirTraceInfo(value) => { - Self::FirTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - TraceInfoRef::PliTraceInfo(value) => { - Self::PliTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - TraceInfoRef::RtpTraceInfo(value) => { - Self::RtpTraceInfo(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for TraceInfoRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::KeyFrameTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::FirTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::PliTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::RtpTraceInfo( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:65` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct KeyFrameTraceInfo { - /// The field `rtp_packet` in the table `KeyFrameTraceInfo` - pub rtp_packet: ::planus::alloc::boxed::Box, - /// The field `is_rtx` in the table `KeyFrameTraceInfo` - pub is_rtx: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for KeyFrameTraceInfo { - fn default() -> Self { - Self { - rtp_packet: ::core::default::Default::default(), - is_rtx: false, - } - } - } - - impl KeyFrameTraceInfo { - /// Creates a [KeyFrameTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> KeyFrameTraceInfoBuilder<()> { - KeyFrameTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_packet: impl ::planus::WriteAs<::planus::Offset>, - field_is_rtx: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_rtp_packet = field_rtp_packet.prepare(builder); - let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_is_rtx.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_packet); - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - object_writer.write::<_, _, 1>(&prepared_is_rtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for KeyFrameTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for KeyFrameTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) - } - } - - /// Builder for serializing an instance of the [KeyFrameTraceInfo] type. - /// - /// Can be created using the [KeyFrameTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct KeyFrameTraceInfoBuilder(State); - - impl KeyFrameTraceInfoBuilder<()> { - /// Setter for the [`rtp_packet` field](KeyFrameTraceInfo#structfield.rtp_packet). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - KeyFrameTraceInfoBuilder((value,)) - } - } - - impl KeyFrameTraceInfoBuilder<(T0,)> { - /// Setter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T1) -> KeyFrameTraceInfoBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - KeyFrameTraceInfoBuilder((v0, value)) - } - - /// Sets the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx_as_default( - self, - ) -> KeyFrameTraceInfoBuilder<(T0, ::planus::DefaultValue)> { - self.is_rtx(::planus::DefaultValue) - } - } - - impl KeyFrameTraceInfoBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [KeyFrameTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for KeyFrameTraceInfoBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - KeyFrameTraceInfo::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [KeyFrameTraceInfo]. - #[derive(Copy, Clone)] - pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> KeyFrameTraceInfoRef<'a> { - /// Getter for the [`rtp_packet` field](KeyFrameTraceInfo#structfield.rtp_packet). - #[inline] - pub fn rtp_packet(&self) -> ::planus::Result> { - self.0.access_required(0, "KeyFrameTraceInfo", "rtp_packet") - } - - /// Getter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). - #[inline] - pub fn is_rtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "KeyFrameTraceInfo", "is_rtx")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for KeyFrameTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("KeyFrameTraceInfoRef"); - f.field("rtp_packet", &self.rtp_packet()); - f.field("is_rtx", &self.is_rtx()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for KeyFrameTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: KeyFrameTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_packet: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_packet()?)?, - ), - is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for KeyFrameTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[KeyFrameTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for KeyFrameTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for KeyFrameTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[KeyFrameTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `FirTraceInfo` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:70` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct FirTraceInfo { - /// The field `ssrc` in the table `FirTraceInfo` - pub ssrc: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for FirTraceInfo { - fn default() -> Self { - Self { ssrc: 0 } - } - } - - impl FirTraceInfo { - /// Creates a [FirTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> FirTraceInfoBuilder<()> { - FirTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for FirTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for FirTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - FirTraceInfo::create(builder, self.ssrc) - } - } - - /// Builder for serializing an instance of the [FirTraceInfo] type. - /// - /// Can be created using the [FirTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct FirTraceInfoBuilder(State); - - impl FirTraceInfoBuilder<()> { - /// Setter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> FirTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - FirTraceInfoBuilder((value,)) - } - - /// Sets the [`ssrc` field](FirTraceInfo#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> FirTraceInfoBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl FirTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [FirTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> for FirTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for FirTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for FirTraceInfoBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - FirTraceInfo::create(builder, v0) - } - } - - /// Reference to a deserialized [FirTraceInfo]. - #[derive(Copy, Clone)] - pub struct FirTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> FirTraceInfoRef<'a> { - /// Getter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "FirTraceInfo", "ssrc")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for FirTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("FirTraceInfoRef"); - f.field("ssrc", &self.ssrc()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for FirTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: FirTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for FirTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for FirTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[FirTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for FirTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for FirTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[FirTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `PliTraceInfo` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:74` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct PliTraceInfo { - /// The field `ssrc` in the table `PliTraceInfo` - pub ssrc: u32, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for PliTraceInfo { - fn default() -> Self { - Self { ssrc: 0 } - } - } - - impl PliTraceInfo { - /// Creates a [PliTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> PliTraceInfoBuilder<()> { - PliTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for PliTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for PliTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PliTraceInfo::create(builder, self.ssrc) - } - } - - /// Builder for serializing an instance of the [PliTraceInfo] type. - /// - /// Can be created using the [PliTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct PliTraceInfoBuilder(State); - - impl PliTraceInfoBuilder<()> { - /// Setter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> PliTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - PliTraceInfoBuilder((value,)) - } - - /// Sets the [`ssrc` field](PliTraceInfo#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> PliTraceInfoBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl PliTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PliTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> for PliTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for PliTraceInfoBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> ::planus::WriteAsOffset - for PliTraceInfoBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - PliTraceInfo::create(builder, v0) - } - } - - /// Reference to a deserialized [PliTraceInfo]. - #[derive(Copy, Clone)] - pub struct PliTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> PliTraceInfoRef<'a> { - /// Getter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "PliTraceInfo", "ssrc")?.unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for PliTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("PliTraceInfoRef"); - f.field("ssrc", &self.ssrc()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for PliTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: PliTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for PliTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for PliTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[PliTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for PliTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for PliTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[PliTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtpTraceInfo` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:78` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtpTraceInfo { - /// The field `rtp_packet` in the table `RtpTraceInfo` - pub rtp_packet: ::planus::alloc::boxed::Box, - /// The field `is_rtx` in the table `RtpTraceInfo` - pub is_rtx: bool, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RtpTraceInfo { - fn default() -> Self { - Self { - rtp_packet: ::core::default::Default::default(), - is_rtx: false, - } - } - } - - impl RtpTraceInfo { - /// Creates a [RtpTraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtpTraceInfoBuilder<()> { - RtpTraceInfoBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_rtp_packet: impl ::planus::WriteAs<::planus::Offset>, - field_is_rtx: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_rtp_packet = field_rtp_packet.prepare(builder); - let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_is_rtx.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_packet); - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - object_writer.write::<_, _, 1>(&prepared_is_rtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtpTraceInfo { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtpTraceInfo { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) - } - } - - /// Builder for serializing an instance of the [RtpTraceInfo] type. - /// - /// Can be created using the [RtpTraceInfo::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtpTraceInfoBuilder(State); - - impl RtpTraceInfoBuilder<()> { - /// Setter for the [`rtp_packet` field](RtpTraceInfo#structfield.rtp_packet). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_packet(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtpTraceInfoBuilder((value,)) - } - } - - impl RtpTraceInfoBuilder<(T0,)> { - /// Setter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T1) -> RtpTraceInfoBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - RtpTraceInfoBuilder((v0, value)) - } - - /// Sets the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn is_rtx_as_default( - self, - ) -> RtpTraceInfoBuilder<(T0, ::planus::DefaultValue)> { - self.is_rtx(::planus::DefaultValue) - } - } - - impl RtpTraceInfoBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpTraceInfo]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for RtpTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for RtpTraceInfoBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for RtpTraceInfoBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - RtpTraceInfo::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [RtpTraceInfo]. - #[derive(Copy, Clone)] - pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtpTraceInfoRef<'a> { - /// Getter for the [`rtp_packet` field](RtpTraceInfo#structfield.rtp_packet). - #[inline] - pub fn rtp_packet(&self) -> ::planus::Result> { - self.0.access_required(0, "RtpTraceInfo", "rtp_packet") - } - - /// Getter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). - #[inline] - pub fn is_rtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for RtpTraceInfoRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtpTraceInfoRef"); - f.field("rtp_packet", &self.rtp_packet()); - f.field("is_rtx", &self.is_rtx()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtpTraceInfo { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtpTraceInfoRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - rtp_packet: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_packet()?)?, - ), - is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtpTraceInfoRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtpTraceInfoRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtpTraceInfoRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtpTraceInfo { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtpTraceInfoRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[RtpTraceInfoRef]", "read_as_root", 0) - }) - } - } - - /// The table `TraceNotification` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:83` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct TraceNotification { - /// The field `type` in the table `TraceNotification` - pub type_: self::TraceEventType, - /// The field `timestamp` in the table `TraceNotification` - pub timestamp: u64, - /// The field `direction` in the table `TraceNotification` - pub direction: super::common::TraceDirection, - /// The field `info` in the table `TraceNotification` - pub info: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for TraceNotification { - fn default() -> Self { - Self { - type_: self::TraceEventType::Keyframe, - timestamp: 0, - direction: super::common::TraceDirection::DirectionIn, - info: ::core::default::Default::default(), - } - } - } - - impl TraceNotification { - /// Creates a [TraceNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceNotificationBuilder<()> { - TraceNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault< - self::TraceEventType, - self::TraceEventType, - >, - field_timestamp: impl ::planus::WriteAsDefault, - field_direction: impl ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - field_info: impl ::planus::WriteAsOptionalUnion, - ) -> ::planus::Offset { - let prepared_type_ = - field_type_.prepare(builder, &self::TraceEventType::Keyframe); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = field_direction - .prepare(builder, &super::common::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - if prepared_timestamp.is_some() { - table_writer.write_entry::(1); - } - if prepared_info.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_type_.is_some() { - table_writer.write_entry::(0); - } - if prepared_direction.is_some() { - table_writer.write_entry::(2); - } - if prepared_info.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_timestamp) = - prepared_timestamp - { - object_writer.write::<_, _, 8>(&prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - object_writer.write::<_, _, 4>(&prepared_info.offset()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_direction) = - prepared_direction - { - object_writer.write::<_, _, 1>(&prepared_direction); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - object_writer.write::<_, _, 1>(&prepared_info.tag()); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for TraceNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for TraceNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - TraceNotification::create( - builder, - self.type_, - self.timestamp, - self.direction, - &self.info, - ) - } - } - - /// Builder for serializing an instance of the [TraceNotification] type. - /// - /// Can be created using the [TraceNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TraceNotificationBuilder(State); - - impl TraceNotificationBuilder<()> { - /// Setter for the [`type` field](TraceNotification#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - TraceNotificationBuilder((value,)) - } - - /// Sets the [`type` field](TraceNotification#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> TraceNotificationBuilder<(::planus::DefaultValue,)> { - self.type_(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0,)> { - /// Setter for the [`timestamp` field](TraceNotification#structfield.timestamp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T1) -> TraceNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - TraceNotificationBuilder((v0, value)) - } - - /// Sets the [`timestamp` field](TraceNotification#structfield.timestamp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn timestamp_as_default( - self, - ) -> TraceNotificationBuilder<(T0, ::planus::DefaultValue)> { - self.timestamp(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0, T1)> { - /// Setter for the [`direction` field](TraceNotification#structfield.direction). - #[inline] - #[allow(clippy::type_complexity)] - pub fn direction(self, value: T2) -> TraceNotificationBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - { - let (v0, v1) = self.0; - TraceNotificationBuilder((v0, v1, value)) - } - - /// Sets the [`direction` field](TraceNotification#structfield.direction) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn direction_as_default( - self, - ) -> TraceNotificationBuilder<(T0, T1, ::planus::DefaultValue)> { - self.direction(::planus::DefaultValue) - } - } - - impl TraceNotificationBuilder<(T0, T1, T2)> { - /// Setter for the [`info` field](TraceNotification#structfield.info). - #[inline] - #[allow(clippy::type_complexity)] - pub fn info(self, value: T3) -> TraceNotificationBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptionalUnion, - { - let (v0, v1, v2) = self.0; - TraceNotificationBuilder((v0, v1, v2, value)) - } - - /// Sets the [`info` field](TraceNotification#structfield.info) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn info_as_null(self) -> TraceNotificationBuilder<(T0, T1, T2, ())> { - self.info(()) - } - } - - impl TraceNotificationBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TraceNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAs<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault< - super::common::TraceDirection, - super::common::TraceDirection, - >, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOffset - for TraceNotificationBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - TraceNotification::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [TraceNotification]. - #[derive(Copy, Clone)] - pub struct TraceNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TraceNotificationRef<'a> { - /// Getter for the [`type` field](TraceNotification#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "TraceNotification", "type_")? - .unwrap_or(self::TraceEventType::Keyframe), - ) - } - - /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). - #[inline] - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "TraceNotification", "timestamp")? - .unwrap_or(0), - ) - } - - /// Getter for the [`direction` field](TraceNotification#structfield.direction). - #[inline] - pub fn direction(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "TraceNotification", "direction")? - .unwrap_or(super::common::TraceDirection::DirectionIn), - ) - } - - /// Getter for the [`info` field](TraceNotification#structfield.info). - #[inline] - pub fn info( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access_union(3, "TraceNotification", "info") - } - } - - impl<'a> ::core::fmt::Debug for TraceNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("TraceNotificationRef"); - f.field("type_", &self.type_()); - f.field("timestamp", &self.timestamp()); - f.field("direction", &self.direction()); - if let ::core::option::Option::Some(field_info) = self.info().transpose() { - f.field("info", &field_info); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for TraceNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: TraceNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - timestamp: ::core::convert::TryInto::try_into(value.timestamp()?)?, - direction: ::core::convert::TryInto::try_into(value.direction()?)?, - info: if let ::core::option::Option::Some(info) = value.info()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(info)?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for TraceNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[TraceNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for TraceNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for TraceNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[TraceNotificationRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.PipeTransport` - /// - /// Generated from these locations: - /// * File `../worker/fbs/pipeTransport.fbs` - pub mod pipe_transport { - /// The table `PipeTransportOptions` in the namespace `FBS.PipeTransport` - /// - /// Generated from these locations: - /// * Table `PipeTransportOptions` in the file `../worker/fbs/pipeTransport.fbs:6` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct PipeTransportOptions { - /// The field `base` in the table `PipeTransportOptions` - pub base: ::planus::alloc::boxed::Box, - /// The field `listen_info` in the table `PipeTransportOptions` - pub listen_info: ::planus::alloc::boxed::Box, - /// The field `enable_rtx` in the table `PipeTransportOptions` - pub enable_rtx: bool, - /// The field `enable_srtp` in the table `PipeTransportOptions` - pub enable_srtp: bool, - } - - impl PipeTransportOptions { - /// Creates a [PipeTransportOptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> PipeTransportOptionsBuilder<()> { - PipeTransportOptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_listen_info: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_enable_rtx: impl ::planus::WriteAsDefault, - field_enable_srtp: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_listen_info = field_listen_info.prepare(builder); - let prepared_enable_rtx = field_enable_rtx.prepare(builder, &false); - let prepared_enable_srtp = field_enable_srtp.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_enable_rtx.is_some() { - table_writer.write_entry::(2); - } - if prepared_enable_srtp.is_some() { - table_writer.write_entry::(3); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_listen_info); - if let ::core::option::Option::Some(prepared_enable_rtx) = - prepared_enable_rtx - { - object_writer.write::<_, _, 1>(&prepared_enable_rtx); - } - if let ::core::option::Option::Some(prepared_enable_srtp) = - prepared_enable_srtp - { - object_writer.write::<_, _, 1>(&prepared_enable_srtp); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for PipeTransportOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for PipeTransportOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for PipeTransportOptions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PipeTransportOptions::create( - builder, - &self.base, - &self.listen_info, - self.enable_rtx, - self.enable_srtp, - ) - } - } - - /// Builder for serializing an instance of the [PipeTransportOptions] type. - /// - /// Can be created using the [PipeTransportOptions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct PipeTransportOptionsBuilder(State); - - impl PipeTransportOptionsBuilder<()> { - /// Setter for the [`base` field](PipeTransportOptions#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> PipeTransportOptionsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - PipeTransportOptionsBuilder((value,)) - } - } - - impl PipeTransportOptionsBuilder<(T0,)> { - /// Setter for the [`listen_info` field](PipeTransportOptions#structfield.listen_info). - #[inline] - #[allow(clippy::type_complexity)] - pub fn listen_info(self, value: T1) -> PipeTransportOptionsBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - PipeTransportOptionsBuilder((v0, value)) - } - } - - impl PipeTransportOptionsBuilder<(T0, T1)> { - /// Setter for the [`enable_rtx` field](PipeTransportOptions#structfield.enable_rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_rtx(self, value: T2) -> PipeTransportOptionsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - PipeTransportOptionsBuilder((v0, v1, value)) - } - - /// Sets the [`enable_rtx` field](PipeTransportOptions#structfield.enable_rtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_rtx_as_default( - self, - ) -> PipeTransportOptionsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.enable_rtx(::planus::DefaultValue) - } - } - - impl PipeTransportOptionsBuilder<(T0, T1, T2)> { - /// Setter for the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_srtp( - self, - value: T3, - ) -> PipeTransportOptionsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - PipeTransportOptionsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_srtp_as_default( - self, - ) -> PipeTransportOptionsBuilder<(T0, T1, T2, ::planus::DefaultValue)> - { - self.enable_srtp(::planus::DefaultValue) - } - } - - impl PipeTransportOptionsBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PipeTransportOptions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for PipeTransportOptionsBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for PipeTransportOptionsBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for PipeTransportOptionsBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - PipeTransportOptions::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [PipeTransportOptions]. - #[derive(Copy, Clone)] - pub struct PipeTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> PipeTransportOptionsRef<'a> { - /// Getter for the [`base` field](PipeTransportOptions#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "PipeTransportOptions", "base") - } - - /// Getter for the [`listen_info` field](PipeTransportOptions#structfield.listen_info). - #[inline] - pub fn listen_info(&self) -> ::planus::Result> { - self.0 - .access_required(1, "PipeTransportOptions", "listen_info") - } - - /// Getter for the [`enable_rtx` field](PipeTransportOptions#structfield.enable_rtx). - #[inline] - pub fn enable_rtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "PipeTransportOptions", "enable_rtx")? - .unwrap_or(false), - ) - } - - /// Getter for the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp). - #[inline] - pub fn enable_srtp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "PipeTransportOptions", "enable_srtp")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for PipeTransportOptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("PipeTransportOptionsRef"); - f.field("base", &self.base()); - f.field("listen_info", &self.listen_info()); - f.field("enable_rtx", &self.enable_rtx()); - f.field("enable_srtp", &self.enable_srtp()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for PipeTransportOptions { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: PipeTransportOptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - listen_info: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.listen_info()?)?, - ), - enable_rtx: ::core::convert::TryInto::try_into(value.enable_rtx()?)?, - enable_srtp: ::core::convert::TryInto::try_into(value.enable_srtp()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for PipeTransportOptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for PipeTransportOptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[PipeTransportOptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for PipeTransportOptions { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for PipeTransportOptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[PipeTransportOptionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `ConnectRequest` in the namespace `FBS.PipeTransport` - /// - /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/pipeTransport.fbs:13` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConnectRequest { - /// The field `ip` in the table `ConnectRequest` - pub ip: ::planus::alloc::string::String, - /// The field `port` in the table `ConnectRequest` - pub port: ::core::option::Option, - /// The field `srtp_parameters` in the table `ConnectRequest` - pub srtp_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - } - - impl ConnectRequest { - /// Creates a [ConnectRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConnectRequestBuilder<()> { - ConnectRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ip: impl ::planus::WriteAs<::planus::Offset>, - field_port: impl ::planus::WriteAsOptional, - field_srtp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_ip = field_ip.prepare(builder); - let prepared_port = field_port.prepare(builder); - let prepared_srtp_parameters = field_srtp_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_srtp_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_port.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_ip); - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - object_writer.write::<_, _, 4>(&prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - object_writer.write::<_, _, 2>(&prepared_port); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConnectRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectRequest::create(builder, &self.ip, self.port, &self.srtp_parameters) - } - } - - /// Builder for serializing an instance of the [ConnectRequest] type. - /// - /// Can be created using the [ConnectRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConnectRequestBuilder(State); - - impl ConnectRequestBuilder<()> { - /// Setter for the [`ip` field](ConnectRequest#structfield.ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ip(self, value: T0) -> ConnectRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConnectRequestBuilder((value,)) - } - } - - impl ConnectRequestBuilder<(T0,)> { - /// Setter for the [`port` field](ConnectRequest#structfield.port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn port(self, value: T1) -> ConnectRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - ConnectRequestBuilder((v0, value)) - } - - /// Sets the [`port` field](ConnectRequest#structfield.port) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn port_as_null(self) -> ConnectRequestBuilder<(T0, ())> { - self.port(()) - } - } - - impl ConnectRequestBuilder<(T0, T1)> { - /// Setter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters(self, value: T2) -> ConnectRequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1) = self.0; - ConnectRequestBuilder((v0, v1, value)) - } - - /// Sets the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters_as_null(self) -> ConnectRequestBuilder<(T0, T1, ())> { - self.srtp_parameters(()) - } - } - - impl ConnectRequestBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for ConnectRequestBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for ConnectRequestBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOffset for ConnectRequestBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - ConnectRequest::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [ConnectRequest]. - #[derive(Copy, Clone)] - pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConnectRequestRef<'a> { - /// Getter for the [`ip` field](ConnectRequest#structfield.ip). - #[inline] - pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "ConnectRequest", "ip") - } - - /// Getter for the [`port` field](ConnectRequest#structfield.port). - #[inline] - pub fn port(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "ConnectRequest", "port") - } - - /// Getter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). - #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(2, "ConnectRequest", "srtp_parameters") - } - } - - impl<'a> ::core::fmt::Debug for ConnectRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConnectRequestRef"); - f.field("ip", &self.ip()); - if let ::core::option::Option::Some(field_port) = self.port().transpose() { - f.field("port", &field_port); - } - if let ::core::option::Option::Some(field_srtp_parameters) = - self.srtp_parameters().transpose() - { - f.field("srtp_parameters", &field_srtp_parameters); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConnectRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConnectRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ip: ::core::convert::TryInto::try_into(value.ip()?)?, - port: if let ::core::option::Option::Some(port) = value.port()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(port)?) - } else { - ::core::option::Option::None - }, - srtp_parameters: if let ::core::option::Option::Some(srtp_parameters) = - value.srtp_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(srtp_parameters)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConnectRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConnectRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConnectRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConnectRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConnectRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConnectResponse` in the namespace `FBS.PipeTransport` - /// - /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/pipeTransport.fbs:19` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConnectResponse { - /// The field `tuple` in the table `ConnectResponse` - pub tuple: ::planus::alloc::boxed::Box, - } - - impl ConnectResponse { - /// Creates a [ConnectResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConnectResponseBuilder<()> { - ConnectResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_tuple = field_tuple.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_tuple); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConnectResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectResponse::create(builder, &self.tuple) - } - } - - /// Builder for serializing an instance of the [ConnectResponse] type. - /// - /// Can be created using the [ConnectResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConnectResponseBuilder(State); - - impl ConnectResponseBuilder<()> { - /// Setter for the [`tuple` field](ConnectResponse#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T0) -> ConnectResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConnectResponseBuilder((value,)) - } - } - - impl ConnectResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for ConnectResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for ConnectResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for ConnectResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ConnectResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [ConnectResponse]. - #[derive(Copy, Clone)] - pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConnectResponseRef<'a> { - /// Getter for the [`tuple` field](ConnectResponse#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(0, "ConnectResponse", "tuple") - } - } - - impl<'a> ::core::fmt::Debug for ConnectResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConnectResponseRef"); - f.field("tuple", &self.tuple()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConnectResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConnectResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConnectResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConnectResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConnectResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConnectResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConnectResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.PipeTransport` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/pipeTransport.fbs:23` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `base` in the table `DumpResponse` - pub base: ::planus::alloc::boxed::Box, - /// The field `tuple` in the table `DumpResponse` - pub tuple: ::planus::alloc::boxed::Box, - /// The field `rtx` in the table `DumpResponse` - pub rtx: bool, - /// The field `srtp_parameters` in the table `DumpResponse` - pub srtp_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - field_rtx: impl ::planus::WriteAsDefault, - field_srtp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_tuple = field_tuple.prepare(builder); - let prepared_rtx = field_rtx.prepare(builder, &false); - let prepared_srtp_parameters = field_srtp_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_srtp_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_rtx.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_tuple); - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - object_writer.write::<_, _, 4>(&prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_rtx) = prepared_rtx { - object_writer.write::<_, _, 1>(&prepared_rtx); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.base, - &self.tuple, - self.rtx, - &self.srtp_parameters, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`base` field](DumpResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`tuple` field](DumpResponse#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`rtx` field](DumpResponse#structfield.rtx). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - - /// Sets the [`rtx` field](DumpResponse#structfield.rtx) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtx_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.rtx(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, ())> { - self.srtp_parameters(()) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOffset for DumpResponseBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`base` field](DumpResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "DumpResponse", "base") - } - - /// Getter for the [`tuple` field](DumpResponse#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(1, "DumpResponse", "tuple") - } - - /// Getter for the [`rtx` field](DumpResponse#structfield.rtx). - #[inline] - pub fn rtx(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(2, "DumpResponse", "rtx")?.unwrap_or(false), - ) - } - - /// Getter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). - #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(3, "DumpResponse", "srtp_parameters") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("base", &self.base()); - f.field("tuple", &self.tuple()); - f.field("rtx", &self.rtx()); - if let ::core::option::Option::Some(field_srtp_parameters) = - self.srtp_parameters().transpose() - { - f.field("srtp_parameters", &field_srtp_parameters); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - rtx: ::core::convert::TryInto::try_into(value.rtx()?)?, - srtp_parameters: if let ::core::option::Option::Some(srtp_parameters) = - value.srtp_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(srtp_parameters)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.PipeTransport` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/pipeTransport.fbs:30` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `base` in the table `GetStatsResponse` - pub base: ::planus::alloc::boxed::Box, - /// The field `tuple` in the table `GetStatsResponse` - pub tuple: ::planus::alloc::boxed::Box, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_tuple = field_tuple.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_tuple); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create(builder, &self.base, &self.tuple) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - GetStatsResponseBuilder((value,)) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Setter for the [`tuple` field](GetStatsResponse#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - GetStatsResponseBuilder((v0, value)) - } - } - - impl GetStatsResponseBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - GetStatsResponse::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "GetStatsResponse", "base") - } - - /// Getter for the [`tuple` field](GetStatsResponse#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(1, "GetStatsResponse", "tuple") - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("base", &self.base()); - f.field("tuple", &self.tuple()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - } - /// The namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * File `../worker/fbs/plainTransport.fbs` - pub mod plain_transport { - /// The table `PlainTransportOptions` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `PlainTransportOptions` in the file `../worker/fbs/plainTransport.fbs:7` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct PlainTransportOptions { - /// The field `base` in the table `PlainTransportOptions` - pub base: ::planus::alloc::boxed::Box, - /// The field `listen_info` in the table `PlainTransportOptions` - pub listen_info: ::planus::alloc::boxed::Box, - /// The field `rtcp_listen_info` in the table `PlainTransportOptions` - pub rtcp_listen_info: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - /// The field `rtcp_mux` in the table `PlainTransportOptions` - pub rtcp_mux: bool, - /// The field `comedia` in the table `PlainTransportOptions` - pub comedia: bool, - /// The field `enable_srtp` in the table `PlainTransportOptions` - pub enable_srtp: bool, - /// The field `srtp_crypto_suite` in the table `PlainTransportOptions` - pub srtp_crypto_suite: - ::core::option::Option, - } - - impl PlainTransportOptions { - /// Creates a [PlainTransportOptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> PlainTransportOptionsBuilder<()> { - PlainTransportOptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_listen_info: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtcp_listen_info: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_rtcp_mux: impl ::planus::WriteAsDefault, - field_comedia: impl ::planus::WriteAsDefault, - field_enable_srtp: impl ::planus::WriteAsDefault, - field_srtp_crypto_suite: impl ::planus::WriteAsOptional< - super::srtp_parameters::SrtpCryptoSuite, - >, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_listen_info = field_listen_info.prepare(builder); - let prepared_rtcp_listen_info = field_rtcp_listen_info.prepare(builder); - let prepared_rtcp_mux = field_rtcp_mux.prepare(builder, &false); - let prepared_comedia = field_comedia.prepare(builder, &false); - let prepared_enable_srtp = field_enable_srtp.prepare(builder, &false); - let prepared_srtp_crypto_suite = field_srtp_crypto_suite.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<18> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_rtcp_listen_info.is_some() { - table_writer - .write_entry::<::planus::Offset>(2); - } - if prepared_rtcp_mux.is_some() { - table_writer.write_entry::(3); - } - if prepared_comedia.is_some() { - table_writer.write_entry::(4); - } - if prepared_enable_srtp.is_some() { - table_writer.write_entry::(5); - } - if prepared_srtp_crypto_suite.is_some() { - table_writer.write_entry::(6); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_listen_info); - if let ::core::option::Option::Some(prepared_rtcp_listen_info) = - prepared_rtcp_listen_info - { - object_writer.write::<_, _, 4>(&prepared_rtcp_listen_info); - } - if let ::core::option::Option::Some(prepared_rtcp_mux) = - prepared_rtcp_mux - { - object_writer.write::<_, _, 1>(&prepared_rtcp_mux); - } - if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia - { - object_writer.write::<_, _, 1>(&prepared_comedia); - } - if let ::core::option::Option::Some(prepared_enable_srtp) = - prepared_enable_srtp - { - object_writer.write::<_, _, 1>(&prepared_enable_srtp); - } - if let ::core::option::Option::Some(prepared_srtp_crypto_suite) = - prepared_srtp_crypto_suite - { - object_writer.write::<_, _, 1>(&prepared_srtp_crypto_suite); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for PlainTransportOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for PlainTransportOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for PlainTransportOptions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PlainTransportOptions::create( - builder, - &self.base, - &self.listen_info, - &self.rtcp_listen_info, - self.rtcp_mux, - self.comedia, - self.enable_srtp, - self.srtp_crypto_suite, - ) - } - } - - /// Builder for serializing an instance of the [PlainTransportOptions] type. - /// - /// Can be created using the [PlainTransportOptions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct PlainTransportOptionsBuilder(State); - - impl PlainTransportOptionsBuilder<()> { - /// Setter for the [`base` field](PlainTransportOptions#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> PlainTransportOptionsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - PlainTransportOptionsBuilder((value,)) - } - } - - impl PlainTransportOptionsBuilder<(T0,)> { - /// Setter for the [`listen_info` field](PlainTransportOptions#structfield.listen_info). - #[inline] - #[allow(clippy::type_complexity)] - pub fn listen_info(self, value: T1) -> PlainTransportOptionsBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - PlainTransportOptionsBuilder((v0, value)) - } - } - - impl PlainTransportOptionsBuilder<(T0, T1)> { - /// Setter for the [`rtcp_listen_info` field](PlainTransportOptions#structfield.rtcp_listen_info). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_listen_info( - self, - value: T2, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1) = self.0; - PlainTransportOptionsBuilder((v0, v1, value)) - } - - /// Sets the [`rtcp_listen_info` field](PlainTransportOptions#structfield.rtcp_listen_info) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_listen_info_as_null( - self, - ) -> PlainTransportOptionsBuilder<(T0, T1, ())> { - self.rtcp_listen_info(()) - } - } - - impl PlainTransportOptionsBuilder<(T0, T1, T2)> { - /// Setter for the [`rtcp_mux` field](PlainTransportOptions#structfield.rtcp_mux). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_mux( - self, - value: T3, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - PlainTransportOptionsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`rtcp_mux` field](PlainTransportOptions#structfield.rtcp_mux) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_mux_as_default( - self, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, ::planus::DefaultValue)> - { - self.rtcp_mux(::planus::DefaultValue) - } - } - - impl PlainTransportOptionsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`comedia` field](PlainTransportOptions#structfield.comedia). - #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia( - self, - value: T4, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - PlainTransportOptionsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`comedia` field](PlainTransportOptions#structfield.comedia) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia_as_default( - self, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.comedia(::planus::DefaultValue) - } - } - - impl PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`enable_srtp` field](PlainTransportOptions#structfield.enable_srtp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_srtp( - self, - value: T5, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - PlainTransportOptionsBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`enable_srtp` field](PlainTransportOptions#structfield.enable_srtp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_srtp_as_default( - self, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.enable_srtp(::planus::DefaultValue) - } - } - - impl PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`srtp_crypto_suite` field](PlainTransportOptions#structfield.srtp_crypto_suite). - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_crypto_suite( - self, - value: T6, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - PlainTransportOptionsBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`srtp_crypto_suite` field](PlainTransportOptions#structfield.srtp_crypto_suite) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_crypto_suite_as_null( - self, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, ())> { - self.srtp_crypto_suite(()) - } - } - - impl PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PlainTransportOptions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsOptional<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsOptional<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsOptional<::planus::Offset>, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6) = &self.0; - PlainTransportOptions::create(builder, v0, v1, v2, v3, v4, v5, v6) - } - } - - /// Reference to a deserialized [PlainTransportOptions]. - #[derive(Copy, Clone)] - pub struct PlainTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> PlainTransportOptionsRef<'a> { - /// Getter for the [`base` field](PlainTransportOptions#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "PlainTransportOptions", "base") - } - - /// Getter for the [`listen_info` field](PlainTransportOptions#structfield.listen_info). - #[inline] - pub fn listen_info(&self) -> ::planus::Result> { - self.0 - .access_required(1, "PlainTransportOptions", "listen_info") - } - - /// Getter for the [`rtcp_listen_info` field](PlainTransportOptions#structfield.rtcp_listen_info). - #[inline] - pub fn rtcp_listen_info( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0 - .access(2, "PlainTransportOptions", "rtcp_listen_info") - } - - /// Getter for the [`rtcp_mux` field](PlainTransportOptions#structfield.rtcp_mux). - #[inline] - pub fn rtcp_mux(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "PlainTransportOptions", "rtcp_mux")? - .unwrap_or(false), - ) - } - - /// Getter for the [`comedia` field](PlainTransportOptions#structfield.comedia). - #[inline] - pub fn comedia(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "PlainTransportOptions", "comedia")? - .unwrap_or(false), - ) - } - - /// Getter for the [`enable_srtp` field](PlainTransportOptions#structfield.enable_srtp). - #[inline] - pub fn enable_srtp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "PlainTransportOptions", "enable_srtp")? - .unwrap_or(false), - ) - } - - /// Getter for the [`srtp_crypto_suite` field](PlainTransportOptions#structfield.srtp_crypto_suite). - #[inline] - pub fn srtp_crypto_suite( - &self, - ) -> ::planus::Result<::core::option::Option> - { - self.0 - .access(6, "PlainTransportOptions", "srtp_crypto_suite") - } - } - - impl<'a> ::core::fmt::Debug for PlainTransportOptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("PlainTransportOptionsRef"); - f.field("base", &self.base()); - f.field("listen_info", &self.listen_info()); - if let ::core::option::Option::Some(field_rtcp_listen_info) = - self.rtcp_listen_info().transpose() - { - f.field("rtcp_listen_info", &field_rtcp_listen_info); - } - f.field("rtcp_mux", &self.rtcp_mux()); - f.field("comedia", &self.comedia()); - f.field("enable_srtp", &self.enable_srtp()); - if let ::core::option::Option::Some(field_srtp_crypto_suite) = - self.srtp_crypto_suite().transpose() - { - f.field("srtp_crypto_suite", &field_srtp_crypto_suite); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for PlainTransportOptions { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: PlainTransportOptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - listen_info: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.listen_info()?)?, - ), - rtcp_listen_info: if let ::core::option::Option::Some(rtcp_listen_info) = - value.rtcp_listen_info()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtcp_listen_info)?, - )) - } else { - ::core::option::Option::None - }, - rtcp_mux: ::core::convert::TryInto::try_into(value.rtcp_mux()?)?, - comedia: ::core::convert::TryInto::try_into(value.comedia()?)?, - enable_srtp: ::core::convert::TryInto::try_into(value.enable_srtp()?)?, - srtp_crypto_suite: if let ::core::option::Option::Some(srtp_crypto_suite) = - value.srtp_crypto_suite()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - srtp_crypto_suite, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for PlainTransportOptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for PlainTransportOptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[PlainTransportOptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for PlainTransportOptions { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for PlainTransportOptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[PlainTransportOptionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `ConnectRequest` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/plainTransport.fbs:17` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConnectRequest { - /// The field `ip` in the table `ConnectRequest` - pub ip: ::core::option::Option<::planus::alloc::string::String>, - /// The field `port` in the table `ConnectRequest` - pub port: ::core::option::Option, - /// The field `rtcp_port` in the table `ConnectRequest` - pub rtcp_port: ::core::option::Option, - /// The field `srtp_parameters` in the table `ConnectRequest` - pub srtp_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ConnectRequest { - fn default() -> Self { - Self { - ip: ::core::default::Default::default(), - port: ::core::default::Default::default(), - rtcp_port: ::core::default::Default::default(), - srtp_parameters: ::core::default::Default::default(), - } - } - } - - impl ConnectRequest { - /// Creates a [ConnectRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConnectRequestBuilder<()> { - ConnectRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ip: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_port: impl ::planus::WriteAsOptional, - field_rtcp_port: impl ::planus::WriteAsOptional, - field_srtp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_ip = field_ip.prepare(builder); - let prepared_port = field_port.prepare(builder); - let prepared_rtcp_port = field_rtcp_port.prepare(builder); - let prepared_srtp_parameters = field_srtp_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<12> = - ::core::default::Default::default(); - if prepared_ip.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } - if prepared_srtp_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_port.is_some() { - table_writer.write_entry::(1); - } - if prepared_rtcp_port.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ip) = prepared_ip { - object_writer.write::<_, _, 4>(&prepared_ip); - } - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - object_writer.write::<_, _, 4>(&prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - object_writer.write::<_, _, 2>(&prepared_port); - } - if let ::core::option::Option::Some(prepared_rtcp_port) = - prepared_rtcp_port - { - object_writer.write::<_, _, 2>(&prepared_rtcp_port); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConnectRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectRequest::create( - builder, - &self.ip, - self.port, - self.rtcp_port, - &self.srtp_parameters, - ) - } - } - - /// Builder for serializing an instance of the [ConnectRequest] type. - /// - /// Can be created using the [ConnectRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConnectRequestBuilder(State); - - impl ConnectRequestBuilder<()> { - /// Setter for the [`ip` field](ConnectRequest#structfield.ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ip(self, value: T0) -> ConnectRequestBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - ConnectRequestBuilder((value,)) - } - - /// Sets the [`ip` field](ConnectRequest#structfield.ip) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ip_as_null(self) -> ConnectRequestBuilder<((),)> { - self.ip(()) - } - } - - impl ConnectRequestBuilder<(T0,)> { - /// Setter for the [`port` field](ConnectRequest#structfield.port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn port(self, value: T1) -> ConnectRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional, - { - let (v0,) = self.0; - ConnectRequestBuilder((v0, value)) - } - - /// Sets the [`port` field](ConnectRequest#structfield.port) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn port_as_null(self) -> ConnectRequestBuilder<(T0, ())> { - self.port(()) - } - } - - impl ConnectRequestBuilder<(T0, T1)> { - /// Setter for the [`rtcp_port` field](ConnectRequest#structfield.rtcp_port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_port(self, value: T2) -> ConnectRequestBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional, - { - let (v0, v1) = self.0; - ConnectRequestBuilder((v0, v1, value)) - } - - /// Sets the [`rtcp_port` field](ConnectRequest#structfield.rtcp_port) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_port_as_null(self) -> ConnectRequestBuilder<(T0, T1, ())> { - self.rtcp_port(()) - } - } - - impl ConnectRequestBuilder<(T0, T1, T2)> { - /// Setter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters( - self, - value: T3, - ) -> ConnectRequestBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2) = self.0; - ConnectRequestBuilder((v0, v1, v2, value)) - } - - /// Sets the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters_as_null(self) -> ConnectRequestBuilder<(T0, T1, T2, ())> { - self.srtp_parameters(()) - } - } - - impl ConnectRequestBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for ConnectRequestBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for ConnectRequestBuilder<(T0, T1, T2, T3)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for ConnectRequestBuilder<(T0, T1, T2, T3)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - ConnectRequest::create(builder, v0, v1, v2, v3) - } - } - - /// Reference to a deserialized [ConnectRequest]. - #[derive(Copy, Clone)] - pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConnectRequestRef<'a> { - /// Getter for the [`ip` field](ConnectRequest#structfield.ip). - #[inline] - pub fn ip( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "ConnectRequest", "ip") - } - - /// Getter for the [`port` field](ConnectRequest#structfield.port). - #[inline] - pub fn port(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "ConnectRequest", "port") - } - - /// Getter for the [`rtcp_port` field](ConnectRequest#structfield.rtcp_port). - #[inline] - pub fn rtcp_port(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(2, "ConnectRequest", "rtcp_port") - } - - /// Getter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). - #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(3, "ConnectRequest", "srtp_parameters") - } - } - - impl<'a> ::core::fmt::Debug for ConnectRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConnectRequestRef"); - if let ::core::option::Option::Some(field_ip) = self.ip().transpose() { - f.field("ip", &field_ip); - } - if let ::core::option::Option::Some(field_port) = self.port().transpose() { - f.field("port", &field_port); - } - if let ::core::option::Option::Some(field_rtcp_port) = - self.rtcp_port().transpose() - { - f.field("rtcp_port", &field_rtcp_port); - } - if let ::core::option::Option::Some(field_srtp_parameters) = - self.srtp_parameters().transpose() - { - f.field("srtp_parameters", &field_srtp_parameters); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConnectRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConnectRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ip: if let ::core::option::Option::Some(ip) = value.ip()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(ip)?) - } else { - ::core::option::Option::None - }, - port: if let ::core::option::Option::Some(port) = value.port()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(port)?) - } else { - ::core::option::Option::None - }, - rtcp_port: if let ::core::option::Option::Some(rtcp_port) = - value.rtcp_port()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - rtcp_port, - )?) - } else { - ::core::option::Option::None - }, - srtp_parameters: if let ::core::option::Option::Some(srtp_parameters) = - value.srtp_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(srtp_parameters)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConnectRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConnectRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConnectRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConnectRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConnectRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConnectResponse` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/plainTransport.fbs:24` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConnectResponse { - /// The field `tuple` in the table `ConnectResponse` - pub tuple: ::planus::alloc::boxed::Box, - /// The field `rtcp_tuple` in the table `ConnectResponse` - pub rtcp_tuple: - ::core::option::Option<::planus::alloc::boxed::Box>, - /// The field `srtp_parameters` in the table `ConnectResponse` - pub srtp_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - } - - impl ConnectResponse { - /// Creates a [ConnectResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConnectResponseBuilder<()> { - ConnectResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - field_rtcp_tuple: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_srtp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_tuple = field_tuple.prepare(builder); - let prepared_rtcp_tuple = field_rtcp_tuple.prepare(builder); - let prepared_srtp_parameters = field_srtp_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_rtcp_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(1); - } - if prepared_srtp_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_tuple); - if let ::core::option::Option::Some(prepared_rtcp_tuple) = - prepared_rtcp_tuple - { - object_writer.write::<_, _, 4>(&prepared_rtcp_tuple); - } - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - object_writer.write::<_, _, 4>(&prepared_srtp_parameters); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConnectResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectResponse::create( - builder, - &self.tuple, - &self.rtcp_tuple, - &self.srtp_parameters, - ) - } - } - - /// Builder for serializing an instance of the [ConnectResponse] type. - /// - /// Can be created using the [ConnectResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConnectResponseBuilder(State); - - impl ConnectResponseBuilder<()> { - /// Setter for the [`tuple` field](ConnectResponse#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T0) -> ConnectResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConnectResponseBuilder((value,)) - } - } - - impl ConnectResponseBuilder<(T0,)> { - /// Setter for the [`rtcp_tuple` field](ConnectResponse#structfield.rtcp_tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple(self, value: T1) -> ConnectResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0,) = self.0; - ConnectResponseBuilder((v0, value)) - } - - /// Sets the [`rtcp_tuple` field](ConnectResponse#structfield.rtcp_tuple) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple_as_null(self) -> ConnectResponseBuilder<(T0, ())> { - self.rtcp_tuple(()) - } - } - - impl ConnectResponseBuilder<(T0, T1)> { - /// Setter for the [`srtp_parameters` field](ConnectResponse#structfield.srtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters(self, value: T2) -> ConnectResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1) = self.0; - ConnectResponseBuilder((v0, v1, value)) - } - - /// Sets the [`srtp_parameters` field](ConnectResponse#structfield.srtp_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters_as_null(self) -> ConnectResponseBuilder<(T0, T1, ())> { - self.srtp_parameters(()) - } - } - - impl ConnectResponseBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset>, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for ConnectResponseBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset>, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for ConnectResponseBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset>, - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for ConnectResponseBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - ConnectResponse::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [ConnectResponse]. - #[derive(Copy, Clone)] - pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConnectResponseRef<'a> { - /// Getter for the [`tuple` field](ConnectResponse#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(0, "ConnectResponse", "tuple") - } - - /// Getter for the [`rtcp_tuple` field](ConnectResponse#structfield.rtcp_tuple). - #[inline] - pub fn rtcp_tuple( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(1, "ConnectResponse", "rtcp_tuple") - } - - /// Getter for the [`srtp_parameters` field](ConnectResponse#structfield.srtp_parameters). - #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(2, "ConnectResponse", "srtp_parameters") - } - } - - impl<'a> ::core::fmt::Debug for ConnectResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConnectResponseRef"); - f.field("tuple", &self.tuple()); - if let ::core::option::Option::Some(field_rtcp_tuple) = - self.rtcp_tuple().transpose() - { - f.field("rtcp_tuple", &field_rtcp_tuple); - } - if let ::core::option::Option::Some(field_srtp_parameters) = - self.srtp_parameters().transpose() - { - f.field("srtp_parameters", &field_srtp_parameters); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConnectResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConnectResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - rtcp_tuple: if let ::core::option::Option::Some(rtcp_tuple) = - value.rtcp_tuple()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtcp_tuple)?, - )) - } else { - ::core::option::Option::None - }, - srtp_parameters: if let ::core::option::Option::Some(srtp_parameters) = - value.srtp_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(srtp_parameters)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConnectResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConnectResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConnectResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConnectResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConnectResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/plainTransport.fbs:30` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `base` in the table `DumpResponse` - pub base: ::planus::alloc::boxed::Box, - /// The field `rtcp_mux` in the table `DumpResponse` - pub rtcp_mux: bool, - /// The field `comedia` in the table `DumpResponse` - pub comedia: bool, - /// The field `tuple` in the table `DumpResponse` - pub tuple: ::planus::alloc::boxed::Box, - /// The field `rtcp_tuple` in the table `DumpResponse` - pub rtcp_tuple: - ::core::option::Option<::planus::alloc::boxed::Box>, - /// The field `srtp_parameters` in the table `DumpResponse` - pub srtp_parameters: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_rtcp_mux: impl ::planus::WriteAsDefault, - field_comedia: impl ::planus::WriteAsDefault, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - field_rtcp_tuple: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_srtp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_rtcp_mux = field_rtcp_mux.prepare(builder, &false); - let prepared_comedia = field_comedia.prepare(builder, &false); - let prepared_tuple = field_tuple.prepare(builder); - let prepared_rtcp_tuple = field_rtcp_tuple.prepare(builder); - let prepared_srtp_parameters = field_srtp_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<16> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(3); - if prepared_rtcp_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_srtp_parameters.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - if prepared_rtcp_mux.is_some() { - table_writer.write_entry::(1); - } - if prepared_comedia.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_tuple); - if let ::core::option::Option::Some(prepared_rtcp_tuple) = - prepared_rtcp_tuple - { - object_writer.write::<_, _, 4>(&prepared_rtcp_tuple); - } - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - object_writer.write::<_, _, 4>(&prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_rtcp_mux) = - prepared_rtcp_mux - { - object_writer.write::<_, _, 1>(&prepared_rtcp_mux); - } - if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia - { - object_writer.write::<_, _, 1>(&prepared_comedia); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.base, - self.rtcp_mux, - self.comedia, - &self.tuple, - &self.rtcp_tuple, - &self.srtp_parameters, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`base` field](DumpResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`rtcp_mux` field](DumpResponse#structfield.rtcp_mux). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_mux(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - - /// Sets the [`rtcp_mux` field](DumpResponse#structfield.rtcp_mux) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_mux_as_default( - self, - ) -> DumpResponseBuilder<(T0, ::planus::DefaultValue)> { - self.rtcp_mux(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`comedia` field](DumpResponse#structfield.comedia). - #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - - /// Sets the [`comedia` field](DumpResponse#structfield.comedia) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.comedia(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`tuple` field](DumpResponse#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtcp_tuple` field](DumpResponse#structfield.rtcp_tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`rtcp_tuple` field](DumpResponse#structfield.rtcp_tuple) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, T3, ())> { - self.rtcp_tuple(()) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional< - ::planus::Offset, - >, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn srtp_parameters_as_null( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { - self.srtp_parameters(()) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional<::planus::Offset>, - T5: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional<::planus::Offset>, - T5: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional<::planus::Offset>, - T5: ::planus::WriteAsOptional< - ::planus::Offset, - >, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`base` field](DumpResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "DumpResponse", "base") - } - - /// Getter for the [`rtcp_mux` field](DumpResponse#structfield.rtcp_mux). - #[inline] - pub fn rtcp_mux(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "DumpResponse", "rtcp_mux")? - .unwrap_or(false), - ) - } - - /// Getter for the [`comedia` field](DumpResponse#structfield.comedia). - #[inline] - pub fn comedia(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "DumpResponse", "comedia")? - .unwrap_or(false), - ) - } - - /// Getter for the [`tuple` field](DumpResponse#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(3, "DumpResponse", "tuple") - } - - /// Getter for the [`rtcp_tuple` field](DumpResponse#structfield.rtcp_tuple). - #[inline] - pub fn rtcp_tuple( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(4, "DumpResponse", "rtcp_tuple") - } - - /// Getter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). - #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result< - ::core::option::Option>, - > { - self.0.access(5, "DumpResponse", "srtp_parameters") - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("base", &self.base()); - f.field("rtcp_mux", &self.rtcp_mux()); - f.field("comedia", &self.comedia()); - f.field("tuple", &self.tuple()); - if let ::core::option::Option::Some(field_rtcp_tuple) = - self.rtcp_tuple().transpose() - { - f.field("rtcp_tuple", &field_rtcp_tuple); - } - if let ::core::option::Option::Some(field_srtp_parameters) = - self.srtp_parameters().transpose() - { - f.field("srtp_parameters", &field_srtp_parameters); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - rtcp_mux: ::core::convert::TryInto::try_into(value.rtcp_mux()?)?, - comedia: ::core::convert::TryInto::try_into(value.comedia()?)?, - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - rtcp_tuple: if let ::core::option::Option::Some(rtcp_tuple) = - value.rtcp_tuple()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtcp_tuple)?, - )) - } else { - ::core::option::Option::None - }, - srtp_parameters: if let ::core::option::Option::Some(srtp_parameters) = - value.srtp_parameters()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(srtp_parameters)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/plainTransport.fbs:39` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `base` in the table `GetStatsResponse` - pub base: ::planus::alloc::boxed::Box, - /// The field `rtcp_mux` in the table `GetStatsResponse` - pub rtcp_mux: bool, - /// The field `comedia` in the table `GetStatsResponse` - pub comedia: bool, - /// The field `tuple` in the table `GetStatsResponse` - pub tuple: ::planus::alloc::boxed::Box, - /// The field `rtcp_tuple` in the table `GetStatsResponse` - pub rtcp_tuple: - ::core::option::Option<::planus::alloc::boxed::Box>, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_rtcp_mux: impl ::planus::WriteAsDefault, - field_comedia: impl ::planus::WriteAsDefault, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - field_rtcp_tuple: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_rtcp_mux = field_rtcp_mux.prepare(builder, &false); - let prepared_comedia = field_comedia.prepare(builder, &false); - let prepared_tuple = field_tuple.prepare(builder); - let prepared_rtcp_tuple = field_rtcp_tuple.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(3); - if prepared_rtcp_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } - if prepared_rtcp_mux.is_some() { - table_writer.write_entry::(1); - } - if prepared_comedia.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_tuple); - if let ::core::option::Option::Some(prepared_rtcp_tuple) = - prepared_rtcp_tuple - { - object_writer.write::<_, _, 4>(&prepared_rtcp_tuple); - } - if let ::core::option::Option::Some(prepared_rtcp_mux) = - prepared_rtcp_mux - { - object_writer.write::<_, _, 1>(&prepared_rtcp_mux); - } - if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia - { - object_writer.write::<_, _, 1>(&prepared_comedia); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create( - builder, - &self.base, - self.rtcp_mux, - self.comedia, - &self.tuple, - &self.rtcp_tuple, - ) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - GetStatsResponseBuilder((value,)) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Setter for the [`rtcp_mux` field](GetStatsResponse#structfield.rtcp_mux). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_mux(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - GetStatsResponseBuilder((v0, value)) - } - - /// Sets the [`rtcp_mux` field](GetStatsResponse#structfield.rtcp_mux) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_mux_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, ::planus::DefaultValue)> { - self.rtcp_mux(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1)> { - /// Setter for the [`comedia` field](GetStatsResponse#structfield.comedia). - #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia(self, value: T2) -> GetStatsResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - GetStatsResponseBuilder((v0, v1, value)) - } - - /// Sets the [`comedia` field](GetStatsResponse#structfield.comedia) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.comedia(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`tuple` field](GetStatsResponse#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T3) -> GetStatsResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - GetStatsResponseBuilder((v0, v1, v2, value)) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtcp_tuple` field](GetStatsResponse#structfield.rtcp_tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple( - self, - value: T4, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1, v2, v3) = self.0; - GetStatsResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`rtcp_tuple` field](GetStatsResponse#structfield.rtcp_tuple) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple_as_null(self) -> GetStatsResponseBuilder<(T0, T1, T2, T3, ())> { - self.rtcp_tuple(()) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOffset - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4) = &self.0; - GetStatsResponse::create(builder, v0, v1, v2, v3, v4) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "GetStatsResponse", "base") - } - - /// Getter for the [`rtcp_mux` field](GetStatsResponse#structfield.rtcp_mux). - #[inline] - pub fn rtcp_mux(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "GetStatsResponse", "rtcp_mux")? - .unwrap_or(false), - ) - } - - /// Getter for the [`comedia` field](GetStatsResponse#structfield.comedia). - #[inline] - pub fn comedia(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "GetStatsResponse", "comedia")? - .unwrap_or(false), - ) - } - - /// Getter for the [`tuple` field](GetStatsResponse#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(3, "GetStatsResponse", "tuple") - } - - /// Getter for the [`rtcp_tuple` field](GetStatsResponse#structfield.rtcp_tuple). - #[inline] - pub fn rtcp_tuple( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(4, "GetStatsResponse", "rtcp_tuple") - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("base", &self.base()); - f.field("rtcp_mux", &self.rtcp_mux()); - f.field("comedia", &self.comedia()); - f.field("tuple", &self.tuple()); - if let ::core::option::Option::Some(field_rtcp_tuple) = - self.rtcp_tuple().transpose() - { - f.field("rtcp_tuple", &field_rtcp_tuple); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - rtcp_mux: ::core::convert::TryInto::try_into(value.rtcp_mux()?)?, - comedia: ::core::convert::TryInto::try_into(value.comedia()?)?, - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - rtcp_tuple: if let ::core::option::Option::Some(rtcp_tuple) = - value.rtcp_tuple()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtcp_tuple)?, - )) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `TupleNotification` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `TupleNotification` in the file `../worker/fbs/plainTransport.fbs:49` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct TupleNotification { - /// The field `tuple` in the table `TupleNotification` - pub tuple: ::planus::alloc::boxed::Box, - } - - impl TupleNotification { - /// Creates a [TupleNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TupleNotificationBuilder<()> { - TupleNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_tuple = field_tuple.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_tuple); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for TupleNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for TupleNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for TupleNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - TupleNotification::create(builder, &self.tuple) - } - } - - /// Builder for serializing an instance of the [TupleNotification] type. - /// - /// Can be created using the [TupleNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct TupleNotificationBuilder(State); - - impl TupleNotificationBuilder<()> { - /// Setter for the [`tuple` field](TupleNotification#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T0) -> TupleNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - TupleNotificationBuilder((value,)) - } - } - - impl TupleNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TupleNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for TupleNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for TupleNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for TupleNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - TupleNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [TupleNotification]. - #[derive(Copy, Clone)] - pub struct TupleNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TupleNotificationRef<'a> { - /// Getter for the [`tuple` field](TupleNotification#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(0, "TupleNotification", "tuple") - } - } - - impl<'a> ::core::fmt::Debug for TupleNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("TupleNotificationRef"); - f.field("tuple", &self.tuple()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for TupleNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: TupleNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for TupleNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for TupleNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[TupleNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for TupleNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for TupleNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[TupleNotificationRef]", "read_as_root", 0) - }) - } - } - - /// The table `RtcpTupleNotification` in the namespace `FBS.PlainTransport` - /// - /// Generated from these locations: - /// * Table `RtcpTupleNotification` in the file `../worker/fbs/plainTransport.fbs:53` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RtcpTupleNotification { - /// The field `tuple` in the table `RtcpTupleNotification` - pub tuple: ::planus::alloc::boxed::Box, - } - - impl RtcpTupleNotification { - /// Creates a [RtcpTupleNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtcpTupleNotificationBuilder<()> { - RtcpTupleNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_tuple = field_tuple.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_tuple); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RtcpTupleNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RtcpTupleNotification { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RtcpTupleNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtcpTupleNotification::create(builder, &self.tuple) - } - } - - /// Builder for serializing an instance of the [RtcpTupleNotification] type. - /// - /// Can be created using the [RtcpTupleNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RtcpTupleNotificationBuilder(State); - - impl RtcpTupleNotificationBuilder<()> { - /// Setter for the [`tuple` field](RtcpTupleNotification#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T0) -> RtcpTupleNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtcpTupleNotificationBuilder((value,)) - } - } - - impl RtcpTupleNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtcpTupleNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for RtcpTupleNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for RtcpTupleNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for RtcpTupleNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - RtcpTupleNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [RtcpTupleNotification]. - #[derive(Copy, Clone)] - pub struct RtcpTupleNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RtcpTupleNotificationRef<'a> { - /// Getter for the [`tuple` field](RtcpTupleNotification#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(0, "RtcpTupleNotification", "tuple") - } - } - - impl<'a> ::core::fmt::Debug for RtcpTupleNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RtcpTupleNotificationRef"); - f.field("tuple", &self.tuple()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RtcpTupleNotification { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RtcpTupleNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RtcpTupleNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RtcpTupleNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RtcpTupleNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RtcpTupleNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RtcpTupleNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[RtcpTupleNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * File `../worker/fbs/webRtcTransport.fbs` - pub mod web_rtc_transport { - /// The table `ListenIndividual` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `ListenIndividual` in the file `../worker/fbs/webRtcTransport.fbs:6` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ListenIndividual { - /// The field `listen_infos` in the table `ListenIndividual` - pub listen_infos: ::planus::alloc::vec::Vec, - } - - impl ListenIndividual { - /// Creates a [ListenIndividualBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ListenIndividualBuilder<()> { - ListenIndividualBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_listen_infos: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - ) -> ::planus::Offset { - let prepared_listen_infos = field_listen_infos.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_listen_infos); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ListenIndividual { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ListenIndividual { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ListenIndividual { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ListenIndividual::create(builder, &self.listen_infos) - } - } - - /// Builder for serializing an instance of the [ListenIndividual] type. - /// - /// Can be created using the [ListenIndividual::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ListenIndividualBuilder(State); - - impl ListenIndividualBuilder<()> { - /// Setter for the [`listen_infos` field](ListenIndividual#structfield.listen_infos). - #[inline] - #[allow(clippy::type_complexity)] - pub fn listen_infos(self, value: T0) -> ListenIndividualBuilder<(T0,)> - where - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - ListenIndividualBuilder((value,)) - } - } - - impl ListenIndividualBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ListenIndividual]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for ListenIndividualBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for ListenIndividualBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset for ListenIndividualBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ListenIndividual::create(builder, v0) - } - } - - /// Reference to a deserialized [ListenIndividual]. - #[derive(Copy, Clone)] - pub struct ListenIndividualRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ListenIndividualRef<'a> { - /// Getter for the [`listen_infos` field](ListenIndividual#structfield.listen_infos). - #[inline] - pub fn listen_infos( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(0, "ListenIndividual", "listen_infos") - } - } - - impl<'a> ::core::fmt::Debug for ListenIndividualRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ListenIndividualRef"); - f.field("listen_infos", &self.listen_infos()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ListenIndividual { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ListenIndividualRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - listen_infos: value.listen_infos()?.to_vec_result()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ListenIndividualRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ListenIndividualRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ListenIndividualRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ListenIndividual { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ListenIndividualRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ListenIndividualRef]", "read_as_root", 0) - }) - } - } - - /// The table `ListenServer` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `ListenServer` in the file `../worker/fbs/webRtcTransport.fbs:10` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ListenServer { - /// The field `web_rtc_server_id` in the table `ListenServer` - pub web_rtc_server_id: ::planus::alloc::string::String, - } - - impl ListenServer { - /// Creates a [ListenServerBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ListenServerBuilder<()> { - ListenServerBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_web_rtc_server_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ListenServer { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ListenServer { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ListenServer { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ListenServer::create(builder, &self.web_rtc_server_id) - } - } - - /// Builder for serializing an instance of the [ListenServer] type. - /// - /// Can be created using the [ListenServer::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ListenServerBuilder(State); - - impl ListenServerBuilder<()> { - /// Setter for the [`web_rtc_server_id` field](ListenServer#structfield.web_rtc_server_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_server_id(self, value: T0) -> ListenServerBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ListenServerBuilder((value,)) - } - } - - impl ListenServerBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ListenServer]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> for ListenServerBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for ListenServerBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> ::planus::WriteAsOffset - for ListenServerBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ListenServer::create(builder, v0) - } - } - - /// Reference to a deserialized [ListenServer]. - #[derive(Copy, Clone)] - pub struct ListenServerRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ListenServerRef<'a> { - /// Getter for the [`web_rtc_server_id` field](ListenServer#structfield.web_rtc_server_id). - #[inline] - pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "ListenServer", "web_rtc_server_id") - } - } - - impl<'a> ::core::fmt::Debug for ListenServerRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ListenServerRef"); - f.field("web_rtc_server_id", &self.web_rtc_server_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ListenServer { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ListenServerRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - web_rtc_server_id: ::core::convert::TryInto::try_into( - value.web_rtc_server_id()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ListenServerRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ListenServerRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ListenServerRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ListenServer { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ListenServerRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ListenServerRef]", "read_as_root", 0) - }) - } - } - - /// The union `Listen` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Union `Listen` in the file `../worker/fbs/webRtcTransport.fbs:14` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub enum Listen { - /// The variant of type `ListenIndividual` in the union `Listen` - ListenIndividual(::planus::alloc::boxed::Box), - - /// The variant of type `ListenServer` in the union `Listen` - ListenServer(::planus::alloc::boxed::Box), - } - - impl Listen { - /// Creates a [ListenBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ListenBuilder<::planus::Uninitialized> { - ListenBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_listen_individual( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_listen_server( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for Listen { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::ListenIndividual(value) => { - Self::create_listen_individual(builder, value) - } - Self::ListenServer(value) => Self::create_listen_server(builder, value), - } - } - } - - impl ::planus::WriteAsOptionalUnion for Listen { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Builder for serializing an instance of the [Listen] type. - /// - /// Can be created using the [Listen::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ListenBuilder(T); - - impl ListenBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`ListenIndividual` variant](Listen#variant.ListenIndividual). - #[inline] - pub fn listen_individual( - self, - value: T, - ) -> ListenBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - ListenBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`ListenServer` variant](Listen#variant.ListenServer). - #[inline] - pub fn listen_server( - self, - value: T, - ) -> ListenBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - ListenBuilder(::planus::Initialized(value)) - } - } - - impl ListenBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Listen]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for ListenBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ListenBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - impl ::planus::WriteAsUnion for ListenBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsOptionalUnion for ListenBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) - } - } - - /// Reference to a deserialized [Listen]. - #[derive(Copy, Clone, Debug)] - pub enum ListenRef<'a> { - ListenIndividual(self::ListenIndividualRef<'a>), - ListenServer(self::ListenServerRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for Listen { - type Error = ::planus::Error; - - fn try_from(value: ListenRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - ListenRef::ListenIndividual(value) => { - Self::ListenIndividual(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - ListenRef::ListenServer(value) => { - Self::ListenServer(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for ListenRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::ListenIndividual( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::ListenServer( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - - /// The table `WebRtcTransportOptions` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `WebRtcTransportOptions` in the file `../worker/fbs/webRtcTransport.fbs:19` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct WebRtcTransportOptions { - /// The field `base` in the table `WebRtcTransportOptions` - pub base: ::planus::alloc::boxed::Box, - /// The field `listen` in the table `WebRtcTransportOptions` - pub listen: self::Listen, - /// The field `enable_udp` in the table `WebRtcTransportOptions` - pub enable_udp: bool, - /// The field `enable_tcp` in the table `WebRtcTransportOptions` - pub enable_tcp: bool, - /// The field `prefer_udp` in the table `WebRtcTransportOptions` - pub prefer_udp: bool, - /// The field `prefer_tcp` in the table `WebRtcTransportOptions` - pub prefer_tcp: bool, - } - - impl WebRtcTransportOptions { - /// Creates a [WebRtcTransportOptionsBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> WebRtcTransportOptionsBuilder<()> { - WebRtcTransportOptionsBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_listen: impl ::planus::WriteAsUnion, - field_enable_udp: impl ::planus::WriteAsDefault, - field_enable_tcp: impl ::planus::WriteAsDefault, - field_prefer_udp: impl ::planus::WriteAsDefault, - field_prefer_tcp: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_listen = field_listen.prepare(builder); - let prepared_enable_udp = field_enable_udp.prepare(builder, &true); - let prepared_enable_tcp = field_enable_tcp.prepare(builder, &true); - let prepared_prefer_udp = field_prefer_udp.prepare(builder, &false); - let prepared_prefer_tcp = field_prefer_tcp.prepare(builder, &false); - - let mut table_writer: ::planus::table_writer::TableWriter<18> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(2); - table_writer.write_entry::(1); - if prepared_enable_udp.is_some() { - table_writer.write_entry::(3); - } - if prepared_enable_tcp.is_some() { - table_writer.write_entry::(4); - } - if prepared_prefer_udp.is_some() { - table_writer.write_entry::(5); - } - if prepared_prefer_tcp.is_some() { - table_writer.write_entry::(6); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_listen.offset()); - object_writer.write::<_, _, 1>(&prepared_listen.tag()); - if let ::core::option::Option::Some(prepared_enable_udp) = - prepared_enable_udp - { - object_writer.write::<_, _, 1>(&prepared_enable_udp); - } - if let ::core::option::Option::Some(prepared_enable_tcp) = - prepared_enable_tcp - { - object_writer.write::<_, _, 1>(&prepared_enable_tcp); - } - if let ::core::option::Option::Some(prepared_prefer_udp) = - prepared_prefer_udp - { - object_writer.write::<_, _, 1>(&prepared_prefer_udp); - } - if let ::core::option::Option::Some(prepared_prefer_tcp) = - prepared_prefer_tcp - { - object_writer.write::<_, _, 1>(&prepared_prefer_tcp); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for WebRtcTransportOptions { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for WebRtcTransportOptions - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for WebRtcTransportOptions { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - WebRtcTransportOptions::create( - builder, - &self.base, - &self.listen, - self.enable_udp, - self.enable_tcp, - self.prefer_udp, - self.prefer_tcp, - ) - } - } - - /// Builder for serializing an instance of the [WebRtcTransportOptions] type. - /// - /// Can be created using the [WebRtcTransportOptions::builder] method. - #[derive(Debug)] - #[must_use] - pub struct WebRtcTransportOptionsBuilder(State); - - impl WebRtcTransportOptionsBuilder<()> { - /// Setter for the [`base` field](WebRtcTransportOptions#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> WebRtcTransportOptionsBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - WebRtcTransportOptionsBuilder((value,)) - } - } - - impl WebRtcTransportOptionsBuilder<(T0,)> { - /// Setter for the [`listen` field](WebRtcTransportOptions#structfield.listen). - #[inline] - #[allow(clippy::type_complexity)] - pub fn listen(self, value: T1) -> WebRtcTransportOptionsBuilder<(T0, T1)> - where - T1: ::planus::WriteAsUnion, - { - let (v0,) = self.0; - WebRtcTransportOptionsBuilder((v0, value)) - } - } - - impl WebRtcTransportOptionsBuilder<(T0, T1)> { - /// Setter for the [`enable_udp` field](WebRtcTransportOptions#structfield.enable_udp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_udp( - self, - value: T2, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - WebRtcTransportOptionsBuilder((v0, v1, value)) - } - - /// Sets the [`enable_udp` field](WebRtcTransportOptions#structfield.enable_udp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_udp_as_default( - self, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.enable_udp(::planus::DefaultValue) - } - } - - impl WebRtcTransportOptionsBuilder<(T0, T1, T2)> { - /// Setter for the [`enable_tcp` field](WebRtcTransportOptions#structfield.enable_tcp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_tcp( - self, - value: T3, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - WebRtcTransportOptionsBuilder((v0, v1, v2, value)) - } - - /// Sets the [`enable_tcp` field](WebRtcTransportOptions#structfield.enable_tcp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn enable_tcp_as_default( - self, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2, ::planus::DefaultValue)> - { - self.enable_tcp(::planus::DefaultValue) - } - } - - impl WebRtcTransportOptionsBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`prefer_udp` field](WebRtcTransportOptions#structfield.prefer_udp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn prefer_udp( - self, - value: T4, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - WebRtcTransportOptionsBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`prefer_udp` field](WebRtcTransportOptions#structfield.prefer_udp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn prefer_udp_as_default( - self, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.prefer_udp(::planus::DefaultValue) - } - } - - impl WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`prefer_tcp` field](WebRtcTransportOptions#structfield.prefer_tcp). - #[inline] - #[allow(clippy::type_complexity)] - pub fn prefer_tcp( - self, - value: T5, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - WebRtcTransportOptionsBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`prefer_tcp` field](WebRtcTransportOptions#structfield.prefer_tcp) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn prefer_tcp_as_default( - self, - ) -> WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.prefer_tcp(::planus::DefaultValue) - } - } - - impl WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [WebRtcTransportOptions]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5) = &self.0; - WebRtcTransportOptions::create(builder, v0, v1, v2, v3, v4, v5) - } - } - - /// Reference to a deserialized [WebRtcTransportOptions]. - #[derive(Copy, Clone)] - pub struct WebRtcTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> WebRtcTransportOptionsRef<'a> { - /// Getter for the [`base` field](WebRtcTransportOptions#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "WebRtcTransportOptions", "base") - } - - /// Getter for the [`listen` field](WebRtcTransportOptions#structfield.listen). - #[inline] - pub fn listen(&self) -> ::planus::Result> { - self.0 - .access_union_required(1, "WebRtcTransportOptions", "listen") - } - - /// Getter for the [`enable_udp` field](WebRtcTransportOptions#structfield.enable_udp). - #[inline] - pub fn enable_udp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "WebRtcTransportOptions", "enable_udp")? - .unwrap_or(true), - ) - } - - /// Getter for the [`enable_tcp` field](WebRtcTransportOptions#structfield.enable_tcp). - #[inline] - pub fn enable_tcp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "WebRtcTransportOptions", "enable_tcp")? - .unwrap_or(true), - ) - } - - /// Getter for the [`prefer_udp` field](WebRtcTransportOptions#structfield.prefer_udp). - #[inline] - pub fn prefer_udp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "WebRtcTransportOptions", "prefer_udp")? - .unwrap_or(false), - ) - } - - /// Getter for the [`prefer_tcp` field](WebRtcTransportOptions#structfield.prefer_tcp). - #[inline] - pub fn prefer_tcp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "WebRtcTransportOptions", "prefer_tcp")? - .unwrap_or(false), - ) - } - } - - impl<'a> ::core::fmt::Debug for WebRtcTransportOptionsRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("WebRtcTransportOptionsRef"); - f.field("base", &self.base()); - f.field("listen", &self.listen()); - f.field("enable_udp", &self.enable_udp()); - f.field("enable_tcp", &self.enable_tcp()); - f.field("prefer_udp", &self.prefer_udp()); - f.field("prefer_tcp", &self.prefer_tcp()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for WebRtcTransportOptions { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: WebRtcTransportOptionsRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - listen: ::core::convert::TryInto::try_into(value.listen()?)?, - enable_udp: ::core::convert::TryInto::try_into(value.enable_udp()?)?, - enable_tcp: ::core::convert::TryInto::try_into(value.enable_tcp()?)?, - prefer_udp: ::core::convert::TryInto::try_into(value.prefer_udp()?)?, - prefer_tcp: ::core::convert::TryInto::try_into(value.prefer_tcp()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for WebRtcTransportOptionsRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for WebRtcTransportOptionsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[WebRtcTransportOptionsRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for WebRtcTransportOptions { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for WebRtcTransportOptionsRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[WebRtcTransportOptionsRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The enum `FingerprintAlgorithm` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `FingerprintAlgorithm` in the file `../worker/fbs/webRtcTransport.fbs:28` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum FingerprintAlgorithm { - /// The variant `SHA1` in the enum `FingerprintAlgorithm` - Sha1 = 0, - - /// The variant `SHA224` in the enum `FingerprintAlgorithm` - Sha224 = 1, - - /// The variant `SHA256` in the enum `FingerprintAlgorithm` - Sha256 = 2, - - /// The variant `SHA384` in the enum `FingerprintAlgorithm` - Sha384 = 3, - - /// The variant `SHA512` in the enum `FingerprintAlgorithm` - Sha512 = 4, - } - - impl FingerprintAlgorithm { - /// Array containing all valid variants of FingerprintAlgorithm - pub const ENUM_VALUES: [Self; 5] = [ - Self::Sha1, - Self::Sha224, - Self::Sha256, - Self::Sha384, - Self::Sha512, - ]; - } - - impl ::core::convert::TryFrom for FingerprintAlgorithm { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(FingerprintAlgorithm::Sha1), - 1 => ::core::result::Result::Ok(FingerprintAlgorithm::Sha224), - 2 => ::core::result::Result::Ok(FingerprintAlgorithm::Sha256), - 3 => ::core::result::Result::Ok(FingerprintAlgorithm::Sha384), - 4 => ::core::result::Result::Ok(FingerprintAlgorithm::Sha512), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: FingerprintAlgorithm) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for FingerprintAlgorithm { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for FingerprintAlgorithm { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for FingerprintAlgorithm { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> FingerprintAlgorithm { - *self - } - } - - impl ::planus::WriteAsDefault for FingerprintAlgorithm { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &FingerprintAlgorithm, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for FingerprintAlgorithm { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for FingerprintAlgorithm { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for FingerprintAlgorithm { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "FingerprintAlgorithm", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for FingerprintAlgorithm { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `Fingerprint` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `Fingerprint` in the file `../worker/fbs/webRtcTransport.fbs:36` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Fingerprint { - /// The field `algorithm` in the table `Fingerprint` - pub algorithm: self::FingerprintAlgorithm, - /// The field `value` in the table `Fingerprint` - pub value: ::planus::alloc::string::String, - } - - impl Fingerprint { - /// Creates a [FingerprintBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> FingerprintBuilder<()> { - FingerprintBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_algorithm: impl ::planus::WriteAsDefault< - self::FingerprintAlgorithm, - self::FingerprintAlgorithm, - >, - field_value: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_algorithm = - field_algorithm.prepare(builder, &self::FingerprintAlgorithm::Sha1); - let prepared_value = field_value.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_algorithm.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); - if let ::core::option::Option::Some(prepared_algorithm) = - prepared_algorithm - { - object_writer.write::<_, _, 1>(&prepared_algorithm); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Fingerprint { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for Fingerprint { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for Fingerprint { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - Fingerprint::create(builder, self.algorithm, &self.value) - } - } - - /// Builder for serializing an instance of the [Fingerprint] type. - /// - /// Can be created using the [Fingerprint::builder] method. - #[derive(Debug)] - #[must_use] - pub struct FingerprintBuilder(State); - - impl FingerprintBuilder<()> { - /// Setter for the [`algorithm` field](Fingerprint#structfield.algorithm). - #[inline] - #[allow(clippy::type_complexity)] - pub fn algorithm(self, value: T0) -> FingerprintBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault< - self::FingerprintAlgorithm, - self::FingerprintAlgorithm, - >, - { - FingerprintBuilder((value,)) - } - - /// Sets the [`algorithm` field](Fingerprint#structfield.algorithm) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn algorithm_as_default(self) -> FingerprintBuilder<(::planus::DefaultValue,)> { - self.algorithm(::planus::DefaultValue) - } - } - - impl FingerprintBuilder<(T0,)> { - /// Setter for the [`value` field](Fingerprint#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> FingerprintBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - FingerprintBuilder((v0, value)) - } - } - - impl FingerprintBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Fingerprint]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - self::FingerprintAlgorithm, - self::FingerprintAlgorithm, - >, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for FingerprintBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault< - self::FingerprintAlgorithm, - self::FingerprintAlgorithm, - >, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for FingerprintBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault< - self::FingerprintAlgorithm, - self::FingerprintAlgorithm, - >, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for FingerprintBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - Fingerprint::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [Fingerprint]. - #[derive(Copy, Clone)] - pub struct FingerprintRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> FingerprintRef<'a> { - /// Getter for the [`algorithm` field](Fingerprint#structfield.algorithm). - #[inline] - pub fn algorithm(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "Fingerprint", "algorithm")? - .unwrap_or(self::FingerprintAlgorithm::Sha1), - ) - } - - /// Getter for the [`value` field](Fingerprint#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "Fingerprint", "value") - } - } - - impl<'a> ::core::fmt::Debug for FingerprintRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("FingerprintRef"); - f.field("algorithm", &self.algorithm()); - f.field("value", &self.value()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for Fingerprint { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: FingerprintRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - algorithm: ::core::convert::TryInto::try_into(value.algorithm()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for FingerprintRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for FingerprintRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[FingerprintRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for Fingerprint { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for FingerprintRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[FingerprintRef]", "read_as_root", 0) - }) - } - } - - /// The enum `DtlsRole` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `DtlsRole` in the file `../worker/fbs/webRtcTransport.fbs:41` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum DtlsRole { - /// The variant `AUTO` in the enum `DtlsRole` - Auto = 0, - - /// The variant `CLIENT` in the enum `DtlsRole` - Client = 1, - - /// The variant `SERVER` in the enum `DtlsRole` - Server = 2, - } - - impl DtlsRole { - /// Array containing all valid variants of DtlsRole - pub const ENUM_VALUES: [Self; 3] = [Self::Auto, Self::Client, Self::Server]; - } - - impl ::core::convert::TryFrom for DtlsRole { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(DtlsRole::Auto), - 1 => ::core::result::Result::Ok(DtlsRole::Client), - 2 => ::core::result::Result::Ok(DtlsRole::Server), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: DtlsRole) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for DtlsRole { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for DtlsRole { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for DtlsRole { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> DtlsRole { - *self - } - } - - impl ::planus::WriteAsDefault for DtlsRole { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &DtlsRole, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for DtlsRole { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for DtlsRole { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for DtlsRole { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "DtlsRole", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for DtlsRole { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The enum `DtlsState` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `DtlsState` in the file `../worker/fbs/webRtcTransport.fbs:47` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum DtlsState { - /// The variant `NEW` in the enum `DtlsState` - New = 0, - - /// The variant `CONNECTING` in the enum `DtlsState` - Connecting = 1, - - /// The variant `CONNECTED` in the enum `DtlsState` - Connected = 2, - - /// The variant `FAILED` in the enum `DtlsState` - Failed = 3, - - /// The variant `CLOSED` in the enum `DtlsState` - Closed = 4, - } - - impl DtlsState { - /// Array containing all valid variants of DtlsState - pub const ENUM_VALUES: [Self; 5] = [ - Self::New, - Self::Connecting, - Self::Connected, - Self::Failed, - Self::Closed, - ]; - } - - impl ::core::convert::TryFrom for DtlsState { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(DtlsState::New), - 1 => ::core::result::Result::Ok(DtlsState::Connecting), - 2 => ::core::result::Result::Ok(DtlsState::Connected), - 3 => ::core::result::Result::Ok(DtlsState::Failed), - 4 => ::core::result::Result::Ok(DtlsState::Closed), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: DtlsState) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for DtlsState { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for DtlsState { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for DtlsState { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> DtlsState { - *self - } - } - - impl ::planus::WriteAsDefault for DtlsState { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &DtlsState, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for DtlsState { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for DtlsState { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for DtlsState { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "DtlsState", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for DtlsState { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `DtlsParameters` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `DtlsParameters` in the file `../worker/fbs/webRtcTransport.fbs:55` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DtlsParameters { - /// The field `fingerprints` in the table `DtlsParameters` - pub fingerprints: ::planus::alloc::vec::Vec, - /// The field `role` in the table `DtlsParameters` - pub role: self::DtlsRole, - } - - impl DtlsParameters { - /// Creates a [DtlsParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DtlsParametersBuilder<()> { - DtlsParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_fingerprints: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_role: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_fingerprints = field_fingerprints.prepare(builder); - let prepared_role = field_role.prepare(builder, &self::DtlsRole::Auto); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(0); - if prepared_role.is_some() { - table_writer.write_entry::(1); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_fingerprints); - if let ::core::option::Option::Some(prepared_role) = prepared_role { - object_writer.write::<_, _, 1>(&prepared_role); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DtlsParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DtlsParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DtlsParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DtlsParameters::create(builder, &self.fingerprints, self.role) - } - } - - /// Builder for serializing an instance of the [DtlsParameters] type. - /// - /// Can be created using the [DtlsParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DtlsParametersBuilder(State); - - impl DtlsParametersBuilder<()> { - /// Setter for the [`fingerprints` field](DtlsParameters#structfield.fingerprints). - #[inline] - #[allow(clippy::type_complexity)] - pub fn fingerprints(self, value: T0) -> DtlsParametersBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - DtlsParametersBuilder((value,)) - } - } - - impl DtlsParametersBuilder<(T0,)> { - /// Setter for the [`role` field](DtlsParameters#structfield.role). - #[inline] - #[allow(clippy::type_complexity)] - pub fn role(self, value: T1) -> DtlsParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DtlsParametersBuilder((v0, value)) - } - - /// Sets the [`role` field](DtlsParameters#structfield.role) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn role_as_default( - self, - ) -> DtlsParametersBuilder<(T0, ::planus::DefaultValue)> { - self.role(::planus::DefaultValue) - } - } - - impl DtlsParametersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DtlsParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for DtlsParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for DtlsParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for DtlsParametersBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - DtlsParameters::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [DtlsParameters]. - #[derive(Copy, Clone)] - pub struct DtlsParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DtlsParametersRef<'a> { - /// Getter for the [`fingerprints` field](DtlsParameters#structfield.fingerprints). - #[inline] - pub fn fingerprints( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "DtlsParameters", "fingerprints") - } - - /// Getter for the [`role` field](DtlsParameters#structfield.role). - #[inline] - pub fn role(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "DtlsParameters", "role")? - .unwrap_or(self::DtlsRole::Auto), - ) - } - } - - impl<'a> ::core::fmt::Debug for DtlsParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DtlsParametersRef"); - f.field("fingerprints", &self.fingerprints()); - f.field("role", &self.role()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DtlsParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DtlsParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - fingerprints: value.fingerprints()?.to_vec_result()?, - role: ::core::convert::TryInto::try_into(value.role()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DtlsParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DtlsParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DtlsParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DtlsParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DtlsParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DtlsParametersRef]", "read_as_root", 0) - }) - } - } - - /// The table `IceParameters` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `IceParameters` in the file `../worker/fbs/webRtcTransport.fbs:60` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct IceParameters { - /// The field `username_fragment` in the table `IceParameters` - pub username_fragment: ::planus::alloc::string::String, - /// The field `password` in the table `IceParameters` - pub password: ::planus::alloc::string::String, - /// The field `ice_lite` in the table `IceParameters` - pub ice_lite: bool, - } - - impl IceParameters { - /// Creates a [IceParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> IceParametersBuilder<()> { - IceParametersBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_username_fragment: impl ::planus::WriteAs<::planus::Offset>, - field_password: impl ::planus::WriteAs<::planus::Offset>, - field_ice_lite: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_username_fragment = field_username_fragment.prepare(builder); - let prepared_password = field_password.prepare(builder); - let prepared_ice_lite = field_ice_lite.prepare(builder, &true); - - let mut table_writer: ::planus::table_writer::TableWriter<10> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); - if prepared_ice_lite.is_some() { - table_writer.write_entry::(2); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_username_fragment); - object_writer.write::<_, _, 4>(&prepared_password); - if let ::core::option::Option::Some(prepared_ice_lite) = - prepared_ice_lite - { - object_writer.write::<_, _, 1>(&prepared_ice_lite); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for IceParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for IceParameters { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for IceParameters { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceParameters::create( - builder, - &self.username_fragment, - &self.password, - self.ice_lite, - ) - } - } - - /// Builder for serializing an instance of the [IceParameters] type. - /// - /// Can be created using the [IceParameters::builder] method. - #[derive(Debug)] - #[must_use] - pub struct IceParametersBuilder(State); - - impl IceParametersBuilder<()> { - /// Setter for the [`username_fragment` field](IceParameters#structfield.username_fragment). - #[inline] - #[allow(clippy::type_complexity)] - pub fn username_fragment(self, value: T0) -> IceParametersBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - IceParametersBuilder((value,)) - } - } - - impl IceParametersBuilder<(T0,)> { - /// Setter for the [`password` field](IceParameters#structfield.password). - #[inline] - #[allow(clippy::type_complexity)] - pub fn password(self, value: T1) -> IceParametersBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - IceParametersBuilder((v0, value)) - } - } - - impl IceParametersBuilder<(T0, T1)> { - /// Setter for the [`ice_lite` field](IceParameters#structfield.ice_lite). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_lite(self, value: T2) -> IceParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - IceParametersBuilder((v0, v1, value)) - } - - /// Sets the [`ice_lite` field](IceParameters#structfield.ice_lite) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_lite_as_default( - self, - ) -> IceParametersBuilder<(T0, T1, ::planus::DefaultValue)> { - self.ice_lite(::planus::DefaultValue) - } - } - - impl IceParametersBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IceParameters]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for IceParametersBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for IceParametersBuilder<(T0, T1, T2)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for IceParametersBuilder<(T0, T1, T2)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - IceParameters::create(builder, v0, v1, v2) - } - } - - /// Reference to a deserialized [IceParameters]. - #[derive(Copy, Clone)] - pub struct IceParametersRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> IceParametersRef<'a> { - /// Getter for the [`username_fragment` field](IceParameters#structfield.username_fragment). - #[inline] - pub fn username_fragment(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "IceParameters", "username_fragment") - } - - /// Getter for the [`password` field](IceParameters#structfield.password). - #[inline] - pub fn password(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "IceParameters", "password") - } - - /// Getter for the [`ice_lite` field](IceParameters#structfield.ice_lite). - #[inline] - pub fn ice_lite(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "IceParameters", "ice_lite")? - .unwrap_or(true), - ) - } - } - - impl<'a> ::core::fmt::Debug for IceParametersRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("IceParametersRef"); - f.field("username_fragment", &self.username_fragment()); - f.field("password", &self.password()); - f.field("ice_lite", &self.ice_lite()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for IceParameters { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: IceParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - username_fragment: ::core::convert::TryInto::try_into( - value.username_fragment()?, - )?, - password: ::core::convert::TryInto::try_into(value.password()?)?, - ice_lite: ::core::convert::TryInto::try_into(value.ice_lite()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for IceParametersRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for IceParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[IceParametersRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for IceParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for IceParametersRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[IceParametersRef]", "read_as_root", 0) - }) - } - } - - /// The enum `IceCandidateType` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `IceCandidateType` in the file `../worker/fbs/webRtcTransport.fbs:66` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum IceCandidateType { - /// The variant `HOST` in the enum `IceCandidateType` - Host = 0, - } - - impl IceCandidateType { - /// Array containing all valid variants of IceCandidateType - pub const ENUM_VALUES: [Self; 1] = [Self::Host]; - } - - impl ::core::convert::TryFrom for IceCandidateType { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(IceCandidateType::Host), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: IceCandidateType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for IceCandidateType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for IceCandidateType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for IceCandidateType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> IceCandidateType { - *self - } - } - - impl ::planus::WriteAsDefault for IceCandidateType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &IceCandidateType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for IceCandidateType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for IceCandidateType { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for IceCandidateType { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "IceCandidateType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for IceCandidateType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The enum `IceCandidateTcpType` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `IceCandidateTcpType` in the file `../worker/fbs/webRtcTransport.fbs:70` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum IceCandidateTcpType { - /// The variant `PASSIVE` in the enum `IceCandidateTcpType` - Passive = 0, - } - - impl IceCandidateTcpType { - /// Array containing all valid variants of IceCandidateTcpType - pub const ENUM_VALUES: [Self; 1] = [Self::Passive]; - } - - impl ::core::convert::TryFrom for IceCandidateTcpType { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(IceCandidateTcpType::Passive), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: IceCandidateTcpType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for IceCandidateTcpType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for IceCandidateTcpType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for IceCandidateTcpType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> IceCandidateTcpType { - *self - } - } - - impl ::planus::WriteAsDefault for IceCandidateTcpType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &IceCandidateTcpType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for IceCandidateTcpType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for IceCandidateTcpType { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for IceCandidateTcpType { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "IceCandidateTcpType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for IceCandidateTcpType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The enum `IceRole` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `IceRole` in the file `../worker/fbs/webRtcTransport.fbs:74` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum IceRole { - /// The variant `CONTROLLED` in the enum `IceRole` - Controlled = 0, - - /// The variant `CONTROLLING` in the enum `IceRole` - Controlling = 1, - } - - impl IceRole { - /// Array containing all valid variants of IceRole - pub const ENUM_VALUES: [Self; 2] = [Self::Controlled, Self::Controlling]; - } - - impl ::core::convert::TryFrom for IceRole { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(IceRole::Controlled), - 1 => ::core::result::Result::Ok(IceRole::Controlling), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: IceRole) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for IceRole { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for IceRole { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for IceRole { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> IceRole { - *self - } - } - - impl ::planus::WriteAsDefault for IceRole { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &IceRole, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for IceRole { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for IceRole { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for IceRole { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "IceRole", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for IceRole { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The enum `IceState` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:79` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum IceState { - /// The variant `NEW` in the enum `IceState` - New = 0, - - /// The variant `CONNECTED` in the enum `IceState` - Connected = 1, - - /// The variant `COMPLETED` in the enum `IceState` - Completed = 2, - - /// The variant `DISCONNECTED` in the enum `IceState` - Disconnected = 3, - } - - impl IceState { - /// Array containing all valid variants of IceState - pub const ENUM_VALUES: [Self; 4] = [ - Self::New, - Self::Connected, - Self::Completed, - Self::Disconnected, - ]; - } - - impl ::core::convert::TryFrom for IceState { - type Error = ::planus::errors::UnknownEnumTagKind; - #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result - { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(IceState::New), - 1 => ::core::result::Result::Ok(IceState::Connected), - 2 => ::core::result::Result::Ok(IceState::Completed), - 3 => ::core::result::Result::Ok(IceState::Disconnected), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: IceState) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for IceState { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for IceState { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for IceState { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> IceState { - *self - } - } - - impl ::planus::WriteAsDefault for IceState { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &IceState, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for IceState { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for IceState { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) - } - } - - impl<'buf> ::planus::VectorReadInner<'buf> for IceState { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, - offset: usize, - ) -> ::core::result::Result - { - let value = *buffer.buffer.get_unchecked(offset); - let value: ::core::result::Result = - ::core::convert::TryInto::try_into(value); - value.map_err(|error_kind| { - error_kind.with_error_location( - "IceState", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for IceState { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - - #[inline] - unsafe fn write_values( - values: &[Self], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - i as u32, - ); - } - } - } - - /// The table `IceCandidate` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:86` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct IceCandidate { - /// The field `foundation` in the table `IceCandidate` - pub foundation: ::planus::alloc::string::String, - /// The field `priority` in the table `IceCandidate` - pub priority: u32, - /// The field `ip` in the table `IceCandidate` - pub ip: ::planus::alloc::string::String, - /// The field `protocol` in the table `IceCandidate` - pub protocol: super::transport::Protocol, - /// The field `port` in the table `IceCandidate` - pub port: u16, - /// The field `type` in the table `IceCandidate` - pub type_: self::IceCandidateType, - /// The field `tcp_type` in the table `IceCandidate` - pub tcp_type: ::core::option::Option, - } - - impl IceCandidate { - /// Creates a [IceCandidateBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> IceCandidateBuilder<()> { - IceCandidateBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_foundation: impl ::planus::WriteAs<::planus::Offset>, - field_priority: impl ::planus::WriteAsDefault, - field_ip: impl ::planus::WriteAs<::planus::Offset>, - field_protocol: impl ::planus::WriteAsDefault< - super::transport::Protocol, - super::transport::Protocol, - >, - field_port: impl ::planus::WriteAsDefault, - field_type_: impl ::planus::WriteAsDefault< - self::IceCandidateType, - self::IceCandidateType, - >, - field_tcp_type: impl ::planus::WriteAsOptional, - ) -> ::planus::Offset { - let prepared_foundation = field_foundation.prepare(builder); - let prepared_priority = field_priority.prepare(builder, &0); - let prepared_ip = field_ip.prepare(builder); - let prepared_protocol = - field_protocol.prepare(builder, &super::transport::Protocol::Udp); - let prepared_port = field_port.prepare(builder, &0); - let prepared_type_ = - field_type_.prepare(builder, &self::IceCandidateType::Host); - let prepared_tcp_type = field_tcp_type.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<18> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_priority.is_some() { - table_writer.write_entry::(1); - } - table_writer.write_entry::<::planus::Offset>(2); - if prepared_port.is_some() { - table_writer.write_entry::(4); - } - if prepared_protocol.is_some() { - table_writer.write_entry::(3); - } - if prepared_type_.is_some() { - table_writer.write_entry::(5); - } - if prepared_tcp_type.is_some() { - table_writer.write_entry::(6); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_foundation); - if let ::core::option::Option::Some(prepared_priority) = - prepared_priority - { - object_writer.write::<_, _, 4>(&prepared_priority); - } - object_writer.write::<_, _, 4>(&prepared_ip); - if let ::core::option::Option::Some(prepared_port) = prepared_port { - object_writer.write::<_, _, 2>(&prepared_port); - } - if let ::core::option::Option::Some(prepared_protocol) = - prepared_protocol - { - object_writer.write::<_, _, 1>(&prepared_protocol); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_tcp_type) = - prepared_tcp_type - { - object_writer.write::<_, _, 1>(&prepared_tcp_type); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for IceCandidate { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for IceCandidate { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for IceCandidate { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceCandidate::create( - builder, - &self.foundation, - self.priority, - &self.ip, - self.protocol, - self.port, - self.type_, - self.tcp_type, - ) - } - } - - /// Builder for serializing an instance of the [IceCandidate] type. - /// - /// Can be created using the [IceCandidate::builder] method. - #[derive(Debug)] - #[must_use] - pub struct IceCandidateBuilder(State); - - impl IceCandidateBuilder<()> { - /// Setter for the [`foundation` field](IceCandidate#structfield.foundation). - #[inline] - #[allow(clippy::type_complexity)] - pub fn foundation(self, value: T0) -> IceCandidateBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - IceCandidateBuilder((value,)) - } - } - - impl IceCandidateBuilder<(T0,)> { - /// Setter for the [`priority` field](IceCandidate#structfield.priority). - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority(self, value: T1) -> IceCandidateBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - IceCandidateBuilder((v0, value)) - } - - /// Sets the [`priority` field](IceCandidate#structfield.priority) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn priority_as_default( - self, - ) -> IceCandidateBuilder<(T0, ::planus::DefaultValue)> { - self.priority(::planus::DefaultValue) - } - } - - impl IceCandidateBuilder<(T0, T1)> { - /// Setter for the [`ip` field](IceCandidate#structfield.ip). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ip(self, value: T2) -> IceCandidateBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - IceCandidateBuilder((v0, v1, value)) - } - } - - impl IceCandidateBuilder<(T0, T1, T2)> { - /// Setter for the [`protocol` field](IceCandidate#structfield.protocol). - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol(self, value: T3) -> IceCandidateBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault< - super::transport::Protocol, - super::transport::Protocol, - >, - { - let (v0, v1, v2) = self.0; - IceCandidateBuilder((v0, v1, v2, value)) - } - - /// Sets the [`protocol` field](IceCandidate#structfield.protocol) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn protocol_as_default( - self, - ) -> IceCandidateBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.protocol(::planus::DefaultValue) - } - } - - impl IceCandidateBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`port` field](IceCandidate#structfield.port). - #[inline] - #[allow(clippy::type_complexity)] - pub fn port(self, value: T4) -> IceCandidateBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - IceCandidateBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`port` field](IceCandidate#structfield.port) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn port_as_default( - self, - ) -> IceCandidateBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.port(::planus::DefaultValue) - } - } - - impl IceCandidateBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`type` field](IceCandidate#structfield.type_). - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T5) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - IceCandidateBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`type` field](IceCandidate#structfield.type_) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn type_as_default( - self, - ) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.type_(::planus::DefaultValue) - } - } - - impl IceCandidateBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`tcp_type` field](IceCandidate#structfield.tcp_type). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tcp_type( - self, - value: T6, - ) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsOptional, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - IceCandidateBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`tcp_type` field](IceCandidate#structfield.tcp_type) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn tcp_type_as_null(self) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, ())> { - self.tcp_type(()) - } - } - - impl IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IceCandidate]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault< - super::transport::Protocol, - super::transport::Protocol, - >, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault< - super::transport::Protocol, - super::transport::Protocol, - >, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsDefault< - super::transport::Protocol, - super::transport::Protocol, - >, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6) = &self.0; - IceCandidate::create(builder, v0, v1, v2, v3, v4, v5, v6) - } - } - - /// Reference to a deserialized [IceCandidate]. - #[derive(Copy, Clone)] - pub struct IceCandidateRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> IceCandidateRef<'a> { - /// Getter for the [`foundation` field](IceCandidate#structfield.foundation). - #[inline] - pub fn foundation(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "IceCandidate", "foundation") - } - - /// Getter for the [`priority` field](IceCandidate#structfield.priority). - #[inline] - pub fn priority(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "IceCandidate", "priority")?.unwrap_or(0), - ) - } - - /// Getter for the [`ip` field](IceCandidate#structfield.ip). - #[inline] - pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "IceCandidate", "ip") - } - - /// Getter for the [`protocol` field](IceCandidate#structfield.protocol). - #[inline] - pub fn protocol(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "IceCandidate", "protocol")? - .unwrap_or(super::transport::Protocol::Udp), - ) - } - - /// Getter for the [`port` field](IceCandidate#structfield.port). - #[inline] - pub fn port(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(4, "IceCandidate", "port")?.unwrap_or(0), - ) - } - - /// Getter for the [`type` field](IceCandidate#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "IceCandidate", "type_")? - .unwrap_or(self::IceCandidateType::Host), - ) - } - - /// Getter for the [`tcp_type` field](IceCandidate#structfield.tcp_type). - #[inline] - pub fn tcp_type( - &self, - ) -> ::planus::Result<::core::option::Option> - { - self.0.access(6, "IceCandidate", "tcp_type") - } - } - - impl<'a> ::core::fmt::Debug for IceCandidateRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("IceCandidateRef"); - f.field("foundation", &self.foundation()); - f.field("priority", &self.priority()); - f.field("ip", &self.ip()); - f.field("protocol", &self.protocol()); - f.field("port", &self.port()); - f.field("type_", &self.type_()); - if let ::core::option::Option::Some(field_tcp_type) = - self.tcp_type().transpose() - { - f.field("tcp_type", &field_tcp_type); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for IceCandidate { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: IceCandidateRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - foundation: ::core::convert::TryInto::try_into(value.foundation()?)?, - priority: ::core::convert::TryInto::try_into(value.priority()?)?, - ip: ::core::convert::TryInto::try_into(value.ip()?)?, - protocol: ::core::convert::TryInto::try_into(value.protocol()?)?, - port: ::core::convert::TryInto::try_into(value.port()?)?, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - tcp_type: if let ::core::option::Option::Some(tcp_type) = - value.tcp_type()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - tcp_type, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for IceCandidateRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for IceCandidateRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[IceCandidateRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for IceCandidate { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for IceCandidateRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[IceCandidateRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConnectRequest` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:96` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConnectRequest { - /// The field `dtls_parameters` in the table `ConnectRequest` - pub dtls_parameters: ::planus::alloc::boxed::Box, - } - - impl ConnectRequest { - /// Creates a [ConnectRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConnectRequestBuilder<()> { - ConnectRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_dtls_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - ) -> ::planus::Offset { - let prepared_dtls_parameters = field_dtls_parameters.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_dtls_parameters); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConnectRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectRequest::create(builder, &self.dtls_parameters) - } - } - - /// Builder for serializing an instance of the [ConnectRequest] type. - /// - /// Can be created using the [ConnectRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConnectRequestBuilder(State); - - impl ConnectRequestBuilder<()> { - /// Setter for the [`dtls_parameters` field](ConnectRequest#structfield.dtls_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_parameters(self, value: T0) -> ConnectRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ConnectRequestBuilder((value,)) - } - } - - impl ConnectRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for ConnectRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for ConnectRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for ConnectRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ConnectRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [ConnectRequest]. - #[derive(Copy, Clone)] - pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConnectRequestRef<'a> { - /// Getter for the [`dtls_parameters` field](ConnectRequest#structfield.dtls_parameters). - #[inline] - pub fn dtls_parameters(&self) -> ::planus::Result> { - self.0 - .access_required(0, "ConnectRequest", "dtls_parameters") - } - } - - impl<'a> ::core::fmt::Debug for ConnectRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConnectRequestRef"); - f.field("dtls_parameters", &self.dtls_parameters()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConnectRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConnectRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - dtls_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.dtls_parameters()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConnectRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConnectRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConnectRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConnectRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConnectRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `ConnectResponse` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:100` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct ConnectResponse { - /// The field `dtls_local_role` in the table `ConnectResponse` - pub dtls_local_role: self::DtlsRole, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ConnectResponse { - fn default() -> Self { - Self { - dtls_local_role: self::DtlsRole::Auto, - } - } - } - - impl ConnectResponse { - /// Creates a [ConnectResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ConnectResponseBuilder<()> { - ConnectResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_dtls_local_role: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_dtls_local_role = - field_dtls_local_role.prepare(builder, &self::DtlsRole::Auto); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_dtls_local_role.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_dtls_local_role) = - prepared_dtls_local_role - { - object_writer.write::<_, _, 1>(&prepared_dtls_local_role); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for ConnectResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectResponse::create(builder, self.dtls_local_role) - } - } - - /// Builder for serializing an instance of the [ConnectResponse] type. - /// - /// Can be created using the [ConnectResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct ConnectResponseBuilder(State); - - impl ConnectResponseBuilder<()> { - /// Setter for the [`dtls_local_role` field](ConnectResponse#structfield.dtls_local_role). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_local_role(self, value: T0) -> ConnectResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ConnectResponseBuilder((value,)) - } - - /// Sets the [`dtls_local_role` field](ConnectResponse#structfield.dtls_local_role) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_local_role_as_default( - self, - ) -> ConnectResponseBuilder<(::planus::DefaultValue,)> { - self.dtls_local_role(::planus::DefaultValue) - } - } - - impl ConnectResponseBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for ConnectResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for ConnectResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset for ConnectResponseBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ConnectResponse::create(builder, v0) - } - } - - /// Reference to a deserialized [ConnectResponse]. - #[derive(Copy, Clone)] - pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ConnectResponseRef<'a> { - /// Getter for the [`dtls_local_role` field](ConnectResponse#structfield.dtls_local_role). - #[inline] - pub fn dtls_local_role(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ConnectResponse", "dtls_local_role")? - .unwrap_or(self::DtlsRole::Auto), - ) - } - } - - impl<'a> ::core::fmt::Debug for ConnectResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("ConnectResponseRef"); - f.field("dtls_local_role", &self.dtls_local_role()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for ConnectResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: ConnectResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - dtls_local_role: ::core::convert::TryInto::try_into( - value.dtls_local_role()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for ConnectResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[ConnectResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for ConnectResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for ConnectResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[ConnectResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `DumpResponse` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:104` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DumpResponse { - /// The field `base` in the table `DumpResponse` - pub base: ::planus::alloc::boxed::Box, - /// The field `ice_role` in the table `DumpResponse` - pub ice_role: self::IceRole, - /// The field `ice_parameters` in the table `DumpResponse` - pub ice_parameters: ::planus::alloc::boxed::Box, - /// The field `ice_candidates` in the table `DumpResponse` - pub ice_candidates: ::planus::alloc::vec::Vec, - /// The field `ice_state` in the table `DumpResponse` - pub ice_state: self::IceState, - /// The field `ice_selected_tuple` in the table `DumpResponse` - pub ice_selected_tuple: - ::core::option::Option<::planus::alloc::boxed::Box>, - /// The field `dtls_parameters` in the table `DumpResponse` - pub dtls_parameters: ::planus::alloc::boxed::Box, - /// The field `dtls_state` in the table `DumpResponse` - pub dtls_state: self::DtlsState, - } - - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_ice_role: impl ::planus::WriteAsDefault, - field_ice_parameters: impl ::planus::WriteAs<::planus::Offset>, - field_ice_candidates: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_ice_state: impl ::planus::WriteAsDefault, - field_ice_selected_tuple: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_dtls_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_dtls_state: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_ice_role = - field_ice_role.prepare(builder, &self::IceRole::Controlled); - let prepared_ice_parameters = field_ice_parameters.prepare(builder); - let prepared_ice_candidates = field_ice_candidates.prepare(builder); - let prepared_ice_state = field_ice_state.prepare(builder, &self::IceState::New); - let prepared_ice_selected_tuple = field_ice_selected_tuple.prepare(builder); - let prepared_dtls_parameters = field_dtls_parameters.prepare(builder); - let prepared_dtls_state = - field_dtls_state.prepare(builder, &self::DtlsState::New); - - let mut table_writer: ::planus::table_writer::TableWriter<20> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(2); - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(3); - if prepared_ice_selected_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - table_writer.write_entry::<::planus::Offset>(6); - if prepared_ice_role.is_some() { - table_writer.write_entry::(1); - } - if prepared_ice_state.is_some() { - table_writer.write_entry::(4); - } - if prepared_dtls_state.is_some() { - table_writer.write_entry::(7); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_ice_parameters); - object_writer.write::<_, _, 4>(&prepared_ice_candidates); - if let ::core::option::Option::Some(prepared_ice_selected_tuple) = - prepared_ice_selected_tuple - { - object_writer.write::<_, _, 4>(&prepared_ice_selected_tuple); - } - object_writer.write::<_, _, 4>(&prepared_dtls_parameters); - if let ::core::option::Option::Some(prepared_ice_role) = - prepared_ice_role - { - object_writer.write::<_, _, 1>(&prepared_ice_role); - } - if let ::core::option::Option::Some(prepared_ice_state) = - prepared_ice_state - { - object_writer.write::<_, _, 1>(&prepared_ice_state); - } - if let ::core::option::Option::Some(prepared_dtls_state) = - prepared_dtls_state - { - object_writer.write::<_, _, 1>(&prepared_dtls_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DumpResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( - builder, - &self.base, - self.ice_role, - &self.ice_parameters, - &self.ice_candidates, - self.ice_state, - &self.ice_selected_tuple, - &self.dtls_parameters, - self.dtls_state, - ) - } - } - - /// Builder for serializing an instance of the [DumpResponse] type. - /// - /// Can be created using the [DumpResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpResponseBuilder(State); - - impl DumpResponseBuilder<()> { - /// Setter for the [`base` field](DumpResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> DumpResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - DumpResponseBuilder((value,)) - } - } - - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`ice_role` field](DumpResponse#structfield.ice_role). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_role(self, value: T1) -> DumpResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) - } - - /// Sets the [`ice_role` field](DumpResponse#structfield.ice_role) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_role_as_default( - self, - ) -> DumpResponseBuilder<(T0, ::planus::DefaultValue)> { - self.ice_role(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`ice_parameters` field](DumpResponse#structfield.ice_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_parameters(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`ice_candidates` field](DumpResponse#structfield.ice_candidates). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_candidates(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`ice_state` field](DumpResponse#structfield.ice_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_state(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`ice_state` field](DumpResponse#structfield.ice_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_state_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.ice_state(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`ice_selected_tuple` field](DumpResponse#structfield.ice_selected_tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_selected_tuple( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`ice_selected_tuple` field](DumpResponse#structfield.ice_selected_tuple) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_selected_tuple_as_null( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { - self.ice_selected_tuple(()) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`dtls_parameters` field](DumpResponse#structfield.dtls_parameters). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_parameters( - self, - value: T6, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs<::planus::Offset>, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`dtls_state` field](DumpResponse#structfield.dtls_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_state( - self, - value: T7, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`dtls_state` field](DumpResponse#structfield.dtls_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_state_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.dtls_state(::planus::DefaultValue) - } - } - - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset>, - T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset>, - T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset>, - T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [DumpResponse]. - #[derive(Copy, Clone)] - pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DumpResponseRef<'a> { - /// Getter for the [`base` field](DumpResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "DumpResponse", "base") - } - - /// Getter for the [`ice_role` field](DumpResponse#structfield.ice_role). - #[inline] - pub fn ice_role(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "DumpResponse", "ice_role")? - .unwrap_or(self::IceRole::Controlled), - ) - } - - /// Getter for the [`ice_parameters` field](DumpResponse#structfield.ice_parameters). - #[inline] - pub fn ice_parameters(&self) -> ::planus::Result> { - self.0.access_required(2, "DumpResponse", "ice_parameters") - } - - /// Getter for the [`ice_candidates` field](DumpResponse#structfield.ice_candidates). - #[inline] - pub fn ice_candidates( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(3, "DumpResponse", "ice_candidates") - } - - /// Getter for the [`ice_state` field](DumpResponse#structfield.ice_state). - #[inline] - pub fn ice_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "DumpResponse", "ice_state")? - .unwrap_or(self::IceState::New), - ) - } - - /// Getter for the [`ice_selected_tuple` field](DumpResponse#structfield.ice_selected_tuple). - #[inline] - pub fn ice_selected_tuple( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(5, "DumpResponse", "ice_selected_tuple") - } - - /// Getter for the [`dtls_parameters` field](DumpResponse#structfield.dtls_parameters). - #[inline] - pub fn dtls_parameters(&self) -> ::planus::Result> { - self.0.access_required(6, "DumpResponse", "dtls_parameters") - } - - /// Getter for the [`dtls_state` field](DumpResponse#structfield.dtls_state). - #[inline] - pub fn dtls_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "DumpResponse", "dtls_state")? - .unwrap_or(self::DtlsState::New), - ) - } - } - - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DumpResponseRef"); - f.field("base", &self.base()); - f.field("ice_role", &self.ice_role()); - f.field("ice_parameters", &self.ice_parameters()); - f.field("ice_candidates", &self.ice_candidates()); - f.field("ice_state", &self.ice_state()); - if let ::core::option::Option::Some(field_ice_selected_tuple) = - self.ice_selected_tuple().transpose() - { - f.field("ice_selected_tuple", &field_ice_selected_tuple); - } - f.field("dtls_parameters", &self.dtls_parameters()); - f.field("dtls_state", &self.dtls_state()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for DumpResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - ice_role: ::core::convert::TryInto::try_into(value.ice_role()?)?, - ice_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.ice_parameters()?)?, - ), - ice_candidates: value.ice_candidates()?.to_vec_result()?, - ice_state: ::core::convert::TryInto::try_into(value.ice_state()?)?, - ice_selected_tuple: if let ::core::option::Option::Some( - ice_selected_tuple, - ) = value.ice_selected_tuple()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(ice_selected_tuple)?, - )) - } else { - ::core::option::Option::None - }, - dtls_parameters: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.dtls_parameters()?)?, - ), - dtls_state: ::core::convert::TryInto::try_into(value.dtls_state()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DumpResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `GetStatsResponse` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:115` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `base` in the table `GetStatsResponse` - pub base: ::planus::alloc::boxed::Box, - /// The field `ice_role` in the table `GetStatsResponse` - pub ice_role: self::IceRole, - /// The field `ice_state` in the table `GetStatsResponse` - pub ice_state: self::IceState, - /// The field `ice_selected_tuple` in the table `GetStatsResponse` - pub ice_selected_tuple: - ::core::option::Option<::planus::alloc::boxed::Box>, - /// The field `dtls_state` in the table `GetStatsResponse` - pub dtls_state: self::DtlsState, - } - - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_ice_role: impl ::planus::WriteAsDefault, - field_ice_state: impl ::planus::WriteAsDefault, - field_ice_selected_tuple: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, - field_dtls_state: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_ice_role = - field_ice_role.prepare(builder, &self::IceRole::Controlled); - let prepared_ice_state = field_ice_state.prepare(builder, &self::IceState::New); - let prepared_ice_selected_tuple = field_ice_selected_tuple.prepare(builder); - let prepared_dtls_state = - field_dtls_state.prepare(builder, &self::DtlsState::New); - - let mut table_writer: ::planus::table_writer::TableWriter<14> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - if prepared_ice_selected_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } - if prepared_ice_role.is_some() { - table_writer.write_entry::(1); - } - if prepared_ice_state.is_some() { - table_writer.write_entry::(2); - } - if prepared_dtls_state.is_some() { - table_writer.write_entry::(4); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_base); - if let ::core::option::Option::Some(prepared_ice_selected_tuple) = - prepared_ice_selected_tuple - { - object_writer.write::<_, _, 4>(&prepared_ice_selected_tuple); - } - if let ::core::option::Option::Some(prepared_ice_role) = - prepared_ice_role - { - object_writer.write::<_, _, 1>(&prepared_ice_role); - } - if let ::core::option::Option::Some(prepared_ice_state) = - prepared_ice_state - { - object_writer.write::<_, _, 1>(&prepared_ice_state); - } - if let ::core::option::Option::Some(prepared_dtls_state) = - prepared_dtls_state - { - object_writer.write::<_, _, 1>(&prepared_dtls_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for GetStatsResponse { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create( - builder, - &self.base, - self.ice_role, - self.ice_state, - &self.ice_selected_tuple, - self.dtls_state, - ) - } - } - - /// Builder for serializing an instance of the [GetStatsResponse] type. - /// - /// Can be created using the [GetStatsResponse::builder] method. - #[derive(Debug)] - #[must_use] - pub struct GetStatsResponseBuilder(State); - - impl GetStatsResponseBuilder<()> { - /// Setter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - GetStatsResponseBuilder((value,)) - } - } - - impl GetStatsResponseBuilder<(T0,)> { - /// Setter for the [`ice_role` field](GetStatsResponse#structfield.ice_role). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_role(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> - where - T1: ::planus::WriteAsDefault, - { - let (v0,) = self.0; - GetStatsResponseBuilder((v0, value)) - } - - /// Sets the [`ice_role` field](GetStatsResponse#structfield.ice_role) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_role_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, ::planus::DefaultValue)> { - self.ice_role(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1)> { - /// Setter for the [`ice_state` field](GetStatsResponse#structfield.ice_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_state(self, value: T2) -> GetStatsResponseBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - GetStatsResponseBuilder((v0, v1, value)) - } - - /// Sets the [`ice_state` field](GetStatsResponse#structfield.ice_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_state_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.ice_state(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`ice_selected_tuple` field](GetStatsResponse#structfield.ice_selected_tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_selected_tuple( - self, - value: T3, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsOptional<::planus::Offset>, - { - let (v0, v1, v2) = self.0; - GetStatsResponseBuilder((v0, v1, v2, value)) - } - - /// Sets the [`ice_selected_tuple` field](GetStatsResponse#structfield.ice_selected_tuple) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_selected_tuple_as_null( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, ())> { - self.ice_selected_tuple(()) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`dtls_state` field](GetStatsResponse#structfield.dtls_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_state( - self, - value: T4, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - GetStatsResponseBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`dtls_state` field](GetStatsResponse#structfield.dtls_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_state_as_default( - self, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.dtls_state(::planus::DefaultValue) - } - } - - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3, v4) = &self.0; - GetStatsResponse::create(builder, v0, v1, v2, v3, v4) - } - } - - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`base` field](GetStatsResponse#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "GetStatsResponse", "base") - } - - /// Getter for the [`ice_role` field](GetStatsResponse#structfield.ice_role). - #[inline] - pub fn ice_role(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "GetStatsResponse", "ice_role")? - .unwrap_or(self::IceRole::Controlled), - ) - } - - /// Getter for the [`ice_state` field](GetStatsResponse#structfield.ice_state). - #[inline] - pub fn ice_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "GetStatsResponse", "ice_state")? - .unwrap_or(self::IceState::New), - ) - } - - /// Getter for the [`ice_selected_tuple` field](GetStatsResponse#structfield.ice_selected_tuple). - #[inline] - pub fn ice_selected_tuple( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(3, "GetStatsResponse", "ice_selected_tuple") - } - - /// Getter for the [`dtls_state` field](GetStatsResponse#structfield.dtls_state). - #[inline] - pub fn dtls_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "GetStatsResponse", "dtls_state")? - .unwrap_or(self::DtlsState::New), - ) - } - } - - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("GetStatsResponseRef"); - f.field("base", &self.base()); - f.field("ice_role", &self.ice_role()); - f.field("ice_state", &self.ice_state()); - if let ::core::option::Option::Some(field_ice_selected_tuple) = - self.ice_selected_tuple().transpose() - { - f.field("ice_selected_tuple", &field_ice_selected_tuple); - } - f.field("dtls_state", &self.dtls_state()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - ice_role: ::core::convert::TryInto::try_into(value.ice_role()?)?, - ice_state: ::core::convert::TryInto::try_into(value.ice_state()?)?, - ice_selected_tuple: if let ::core::option::Option::Some( - ice_selected_tuple, - ) = value.ice_selected_tuple()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(ice_selected_tuple)?, - )) - } else { - ::core::option::Option::None - }, - dtls_state: ::core::convert::TryInto::try_into(value.dtls_state()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[GetStatsResponseRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) - }) - } - } - - /// The table `IceSelectedTupleChangeNotification` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:125` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct IceSelectedTupleChangeNotification { - /// The field `tuple` in the table `IceSelectedTupleChangeNotification` - pub tuple: ::planus::alloc::boxed::Box, - } - - impl IceSelectedTupleChangeNotification { - /// Creates a [IceSelectedTupleChangeNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> IceSelectedTupleChangeNotificationBuilder<()> { - IceSelectedTupleChangeNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_tuple = field_tuple.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_tuple); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for IceSelectedTupleChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for IceSelectedTupleChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset - for IceSelectedTupleChangeNotification - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceSelectedTupleChangeNotification::create(builder, &self.tuple) - } - } - - /// Builder for serializing an instance of the [IceSelectedTupleChangeNotification] type. - /// - /// Can be created using the [IceSelectedTupleChangeNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct IceSelectedTupleChangeNotificationBuilder(State); - - impl IceSelectedTupleChangeNotificationBuilder<()> { - /// Setter for the [`tuple` field](IceSelectedTupleChangeNotification#structfield.tuple). - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple( - self, - value: T0, - ) -> IceSelectedTupleChangeNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - IceSelectedTupleChangeNotificationBuilder((value,)) - } - } - - impl IceSelectedTupleChangeNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IceSelectedTupleChangeNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for IceSelectedTupleChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for IceSelectedTupleChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for IceSelectedTupleChangeNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - IceSelectedTupleChangeNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [IceSelectedTupleChangeNotification]. - #[derive(Copy, Clone)] - pub struct IceSelectedTupleChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> IceSelectedTupleChangeNotificationRef<'a> { - /// Getter for the [`tuple` field](IceSelectedTupleChangeNotification#structfield.tuple). - #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0 - .access_required(0, "IceSelectedTupleChangeNotification", "tuple") - } - } - - impl<'a> ::core::fmt::Debug for IceSelectedTupleChangeNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("IceSelectedTupleChangeNotificationRef"); - f.field("tuple", &self.tuple()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for IceSelectedTupleChangeNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from( - value: IceSelectedTupleChangeNotificationRef<'a>, - ) -> ::planus::Result { - ::core::result::Result::Ok(Self { - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for IceSelectedTupleChangeNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for IceSelectedTupleChangeNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[IceSelectedTupleChangeNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for IceSelectedTupleChangeNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for IceSelectedTupleChangeNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[IceSelectedTupleChangeNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `IceStateChangeNotification` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:129` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct IceStateChangeNotification { - /// The field `ice_state` in the table `IceStateChangeNotification` - pub ice_state: self::IceState, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for IceStateChangeNotification { - fn default() -> Self { - Self { - ice_state: self::IceState::New, - } - } - } - - impl IceStateChangeNotification { - /// Creates a [IceStateChangeNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> IceStateChangeNotificationBuilder<()> { - IceStateChangeNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ice_state: impl ::planus::WriteAsDefault, - ) -> ::planus::Offset { - let prepared_ice_state = field_ice_state.prepare(builder, &self::IceState::New); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - if prepared_ice_state.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ice_state) = - prepared_ice_state - { - object_writer.write::<_, _, 1>(&prepared_ice_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for IceStateChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for IceStateChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for IceStateChangeNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceStateChangeNotification::create(builder, self.ice_state) - } - } - - /// Builder for serializing an instance of the [IceStateChangeNotification] type. - /// - /// Can be created using the [IceStateChangeNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct IceStateChangeNotificationBuilder(State); - - impl IceStateChangeNotificationBuilder<()> { - /// Setter for the [`ice_state` field](IceStateChangeNotification#structfield.ice_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_state(self, value: T0) -> IceStateChangeNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - IceStateChangeNotificationBuilder((value,)) - } - - /// Sets the [`ice_state` field](IceStateChangeNotification#structfield.ice_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_state_as_default( - self, - ) -> IceStateChangeNotificationBuilder<(::planus::DefaultValue,)> { - self.ice_state(::planus::DefaultValue) - } - } - - impl IceStateChangeNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IceStateChangeNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl> - ::planus::WriteAs<::planus::Offset> - for IceStateChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl> - ::planus::WriteAsOptional<::planus::Offset> - for IceStateChangeNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl> - ::planus::WriteAsOffset - for IceStateChangeNotificationBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - IceStateChangeNotification::create(builder, v0) - } - } - - /// Reference to a deserialized [IceStateChangeNotification]. - #[derive(Copy, Clone)] - pub struct IceStateChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> IceStateChangeNotificationRef<'a> { - /// Getter for the [`ice_state` field](IceStateChangeNotification#structfield.ice_state). - #[inline] - pub fn ice_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "IceStateChangeNotification", "ice_state")? - .unwrap_or(self::IceState::New), - ) - } - } - - impl<'a> ::core::fmt::Debug for IceStateChangeNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("IceStateChangeNotificationRef"); - f.field("ice_state", &self.ice_state()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for IceStateChangeNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: IceStateChangeNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - ice_state: ::core::convert::TryInto::try_into(value.ice_state()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for IceStateChangeNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for IceStateChangeNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[IceStateChangeNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for IceStateChangeNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for IceStateChangeNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[IceStateChangeNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - - /// The table `DtlsStateChangeNotification` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:133` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct DtlsStateChangeNotification { - /// The field `dtls_state` in the table `DtlsStateChangeNotification` - pub dtls_state: self::DtlsState, - /// The field `remote_cert` in the table `DtlsStateChangeNotification` - pub remote_cert: ::core::option::Option<::planus::alloc::string::String>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for DtlsStateChangeNotification { - fn default() -> Self { - Self { - dtls_state: self::DtlsState::New, - remote_cert: ::core::default::Default::default(), - } - } - } - - impl DtlsStateChangeNotification { - /// Creates a [DtlsStateChangeNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DtlsStateChangeNotificationBuilder<()> { - DtlsStateChangeNotificationBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_dtls_state: impl ::planus::WriteAsDefault, - field_remote_cert: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - ) -> ::planus::Offset { - let prepared_dtls_state = - field_dtls_state.prepare(builder, &self::DtlsState::New); - let prepared_remote_cert = field_remote_cert.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<8> = - ::core::default::Default::default(); - if prepared_remote_cert.is_some() { - table_writer.write_entry::<::planus::Offset>(1); - } - if prepared_dtls_state.is_some() { - table_writer.write_entry::(0); - } - - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_remote_cert) = - prepared_remote_cert - { - object_writer.write::<_, _, 4>(&prepared_remote_cert); - } - if let ::core::option::Option::Some(prepared_dtls_state) = - prepared_dtls_state - { - object_writer.write::<_, _, 1>(&prepared_dtls_state); - } - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> - for DtlsStateChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> - for DtlsStateChangeNotification - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for DtlsStateChangeNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DtlsStateChangeNotification::create(builder, self.dtls_state, &self.remote_cert) - } - } - - /// Builder for serializing an instance of the [DtlsStateChangeNotification] type. - /// - /// Can be created using the [DtlsStateChangeNotification::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DtlsStateChangeNotificationBuilder(State); - - impl DtlsStateChangeNotificationBuilder<()> { - /// Setter for the [`dtls_state` field](DtlsStateChangeNotification#structfield.dtls_state). - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_state(self, value: T0) -> DtlsStateChangeNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - DtlsStateChangeNotificationBuilder((value,)) - } - - /// Sets the [`dtls_state` field](DtlsStateChangeNotification#structfield.dtls_state) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn dtls_state_as_default( - self, - ) -> DtlsStateChangeNotificationBuilder<(::planus::DefaultValue,)> { - self.dtls_state(::planus::DefaultValue) - } - } - - impl DtlsStateChangeNotificationBuilder<(T0,)> { - /// Setter for the [`remote_cert` field](DtlsStateChangeNotification#structfield.remote_cert). - #[inline] - #[allow(clippy::type_complexity)] - pub fn remote_cert( - self, - value: T1, - ) -> DtlsStateChangeNotificationBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0,) = self.0; - DtlsStateChangeNotificationBuilder((v0, value)) - } - - /// Sets the [`remote_cert` field](DtlsStateChangeNotification#structfield.remote_cert) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn remote_cert_as_null(self) -> DtlsStateChangeNotificationBuilder<(T0, ())> { - self.remote_cert(()) - } - } - - impl DtlsStateChangeNotificationBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DtlsStateChangeNotification]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAs<::planus::Offset> - for DtlsStateChangeNotificationBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > - ::planus::WriteAsOptional<::planus::Offset> - for DtlsStateChangeNotificationBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOffset - for DtlsStateChangeNotificationBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - DtlsStateChangeNotification::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [DtlsStateChangeNotification]. - #[derive(Copy, Clone)] - pub struct DtlsStateChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> DtlsStateChangeNotificationRef<'a> { - /// Getter for the [`dtls_state` field](DtlsStateChangeNotification#structfield.dtls_state). - #[inline] - pub fn dtls_state(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "DtlsStateChangeNotification", "dtls_state")? - .unwrap_or(self::DtlsState::New), - ) - } - - /// Getter for the [`remote_cert` field](DtlsStateChangeNotification#structfield.remote_cert). - #[inline] - pub fn remote_cert( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0 - .access(1, "DtlsStateChangeNotification", "remote_cert") - } - } - - impl<'a> ::core::fmt::Debug for DtlsStateChangeNotificationRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("DtlsStateChangeNotificationRef"); - f.field("dtls_state", &self.dtls_state()); - if let ::core::option::Option::Some(field_remote_cert) = - self.remote_cert().transpose() - { - f.field("remote_cert", &field_remote_cert); - } - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> - for DtlsStateChangeNotification - { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: DtlsStateChangeNotificationRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - dtls_state: ::core::convert::TryInto::try_into(value.dtls_state()?)?, - remote_cert: if let ::core::option::Option::Some(remote_cert) = - value.remote_cert()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - remote_cert, - )?) - } else { - ::core::option::Option::None - }, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for DtlsStateChangeNotificationRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for DtlsStateChangeNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[DtlsStateChangeNotificationRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> - for DtlsStateChangeNotification - { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for DtlsStateChangeNotificationRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[DtlsStateChangeNotificationRef]", - "read_as_root", - 0, - ) - }) - } - } - } - /// The namespace `FBS.RtpObserver` - /// - /// Generated from these locations: - /// * File `../worker/fbs/rtpObserver.fbs` - pub mod rtp_observer { - /// The table `AddProducerRequest` in the namespace `FBS.RtpObserver` - /// - /// Generated from these locations: - /// * Table `AddProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:3` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct AddProducerRequest { - /// The field `producer_id` in the table `AddProducerRequest` - pub producer_id: ::planus::alloc::string::String, - } - - impl AddProducerRequest { - /// Creates a [AddProducerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> AddProducerRequestBuilder<()> { - AddProducerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_producer_id = field_producer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for AddProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for AddProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for AddProducerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - AddProducerRequest::create(builder, &self.producer_id) - } - } - - /// Builder for serializing an instance of the [AddProducerRequest] type. - /// - /// Can be created using the [AddProducerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct AddProducerRequestBuilder(State); - - impl AddProducerRequestBuilder<()> { - /// Setter for the [`producer_id` field](AddProducerRequest#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T0) -> AddProducerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - AddProducerRequestBuilder((value,)) - } - } - - impl AddProducerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [AddProducerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for AddProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for AddProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset for AddProducerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - AddProducerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [AddProducerRequest]. - #[derive(Copy, Clone)] - pub struct AddProducerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> AddProducerRequestRef<'a> { - /// Getter for the [`producer_id` field](AddProducerRequest#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "AddProducerRequest", "producer_id") - } - } - - impl<'a> ::core::fmt::Debug for AddProducerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("AddProducerRequestRef"); - f.field("producer_id", &self.producer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for AddProducerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: AddProducerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for AddProducerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for AddProducerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[AddProducerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for AddProducerRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for AddProducerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location("[AddProducerRequestRef]", "read_as_root", 0) - }) - } - } - - /// The table `RemoveProducerRequest` in the namespace `FBS.RtpObserver` - /// - /// Generated from these locations: - /// * Table `RemoveProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:7` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct RemoveProducerRequest { - /// The field `producer_id` in the table `RemoveProducerRequest` - pub producer_id: ::planus::alloc::string::String, - } - - impl RemoveProducerRequest { - /// Creates a [RemoveProducerRequestBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RemoveProducerRequestBuilder<()> { - RemoveProducerRequestBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_producer_id: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_producer_id = field_producer_id.prepare(builder); - - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_producer_id); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for RemoveProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl ::planus::WriteAsOptional<::planus::Offset> for RemoveProducerRequest { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl ::planus::WriteAsOffset for RemoveProducerRequest { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RemoveProducerRequest::create(builder, &self.producer_id) - } - } - - /// Builder for serializing an instance of the [RemoveProducerRequest] type. - /// - /// Can be created using the [RemoveProducerRequest::builder] method. - #[derive(Debug)] - #[must_use] - pub struct RemoveProducerRequestBuilder(State); - - impl RemoveProducerRequestBuilder<()> { - /// Setter for the [`producer_id` field](RemoveProducerRequest#structfield.producer_id). - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T0) -> RemoveProducerRequestBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RemoveProducerRequestBuilder((value,)) - } - } - - impl RemoveProducerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RemoveProducerRequest]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) - } - } - - impl>> - ::planus::WriteAs<::planus::Offset> - for RemoveProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } - - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for RemoveProducerRequestBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } - - impl>> - ::planus::WriteAsOffset - for RemoveProducerRequestBuilder<(T0,)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - RemoveProducerRequest::create(builder, v0) - } - } - - /// Reference to a deserialized [RemoveProducerRequest]. - #[derive(Copy, Clone)] - pub struct RemoveProducerRequestRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> RemoveProducerRequestRef<'a> { - /// Getter for the [`producer_id` field](RemoveProducerRequest#structfield.producer_id). - #[inline] - pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "RemoveProducerRequest", "producer_id") - } - } - - impl<'a> ::core::fmt::Debug for RemoveProducerRequestRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("RemoveProducerRequestRef"); - f.field("producer_id", &self.producer_id()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for RemoveProducerRequest { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: RemoveProducerRequestRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - producer_id: ::core::convert::TryInto::try_into(value.producer_id()?)?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for RemoveProducerRequestRef<'a> { - #[inline] - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) - } - } - - impl<'a> ::planus::VectorReadInner<'a> for RemoveProducerRequestRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - - unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { - error_kind.with_error_location( - "[RemoveProducerRequestRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for RemoveProducerRequest { - type Value = ::planus::Offset; - const STRIDE: usize = 4; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) - } - - #[inline] - unsafe fn write_values( - values: &[::planus::Offset], - bytes: *mut ::core::mem::MaybeUninit, - buffer_position: u32, - ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; - for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) { - ::planus::WriteAsPrimitive::write( - v, - ::planus::Cursor::new(&mut *bytes.add(i)), - buffer_position - (Self::STRIDE * i) as u32, - ); - } - } - } - - impl<'a> ::planus::ReadAsRoot<'a> for RemoveProducerRequestRef<'a> { - fn read_as_root(slice: &'a [u8]) -> ::planus::Result { - ::planus::TableRead::from_buffer( - ::planus::SliceWithStartOffset { - buffer: slice, - offset_from_start: 0, - }, - 0, - ) - .map_err(|error_kind| { - error_kind.with_error_location( - "[RemoveProducerRequestRef]", - "read_as_root", - 0, - ) - }) - } - } - } - } -} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index c55b6f2b8f..7d62f481ed 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -49,7 +49,6 @@ //! and are a good place to start until we have demo apps built in Rust). pub mod data_structures; -pub mod fbs; mod macros; mod messages; #[doc(hidden)] diff --git a/rust/src/messages.rs b/rust/src/messages.rs index a6c09b43df..204ac53b53 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -10,11 +10,6 @@ use crate::data_structures::{ ListenInfo, SctpState, TransportTuple, }; use crate::direct_transport::DirectTransportOptions; -use crate::fbs::{ - active_speaker_observer, audio_level_observer, consumer, data_consumer, data_producer, - direct_transport, message, notification, pipe_transport, plain_transport, producer, request, - response, router, rtp_observer, transport, web_rtc_server, web_rtc_transport, worker, -}; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; use crate::plain_transport::PlainTransportOptions; @@ -35,6 +30,11 @@ use crate::webrtc_transport::{ WebRtcTransportListen, WebRtcTransportListenInfos, WebRtcTransportOptions, }; use crate::worker::{ChannelMessageHandlers, WorkerDump, WorkerUpdateSettings}; +use mediasoup_sys::fbs::{ + active_speaker_observer, audio_level_observer, consumer, data_consumer, data_producer, + direct_transport, message, notification, pipe_transport, plain_transport, producer, request, + response, router, rtp_observer, transport, web_rtc_server, web_rtc_transport, worker, +}; use parking_lot::Mutex; use planus::Builder; use serde::{Deserialize, Serialize}; diff --git a/rust/src/ortc.rs b/rust/src/ortc.rs index f176e477f6..88acf21650 100644 --- a/rust/src/ortc.rs +++ b/rust/src/ortc.rs @@ -1,4 +1,3 @@ -use crate::fbs::rtp_parameters; use crate::rtp_parameters::{ MediaKind, MimeType, MimeTypeAudio, MimeTypeVideo, RtcpFeedback, RtcpParameters, RtpCapabilities, RtpCapabilitiesFinalized, RtpCodecCapability, RtpCodecCapabilityFinalized, @@ -8,6 +7,7 @@ use crate::rtp_parameters::{ }; use crate::scalability_modes::ScalabilityMode; use crate::supported_rtp_capabilities; +use mediasoup_sys::fbs::rtp_parameters; use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::collections::BTreeMap; diff --git a/rust/src/router/active_speaker_observer.rs b/rust/src/router/active_speaker_observer.rs index e7dd9a5207..3707ea9ba0 100644 --- a/rust/src/router/active_speaker_observer.rs +++ b/rust/src/router/active_speaker_observer.rs @@ -2,7 +2,6 @@ mod tests; use crate::data_structures::AppData; -use crate::fbs::notification; use crate::messages::{ RtpObserverAddProducerRequest, RtpObserverCloseRequest, RtpObserverPauseRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, @@ -15,6 +14,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::notification; use parking_lot::Mutex; use serde::Deserialize; use std::fmt; diff --git a/rust/src/router/audio_level_observer.rs b/rust/src/router/audio_level_observer.rs index 0e174c9b39..e696d4c715 100644 --- a/rust/src/router/audio_level_observer.rs +++ b/rust/src/router/audio_level_observer.rs @@ -2,7 +2,6 @@ mod tests; use crate::data_structures::AppData; -use crate::fbs::{audio_level_observer, notification}; use crate::messages::{ RtpObserverAddProducerRequest, RtpObserverCloseRequest, RtpObserverPauseRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, @@ -15,6 +14,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{audio_level_observer, notification}; use parking_lot::Mutex; use serde::Deserialize; use std::fmt; diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index 8280bc8614..cfc6e0697d 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -2,7 +2,6 @@ mod tests; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; -use crate::fbs::{consumer, notification, response, rtp_parameters, rtp_stream, rtx_stream}; use crate::messages::{ ConsumerCloseRequest, ConsumerDumpRequest, ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest, ConsumerPauseRequest, ConsumerRequestKeyFrameRequest, @@ -18,6 +17,9 @@ use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionH use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{ + consumer, notification, response, rtp_parameters, rtp_stream, rtx_stream, +}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::error::Error; diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index 7d8b2bc828..2b7fe52e5b 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -3,7 +3,6 @@ mod tests; use crate::data_producer::{DataProducer, DataProducerId, WeakDataProducer}; use crate::data_structures::{AppData, WebRtcMessage}; -use crate::fbs::{data_consumer, data_producer, notification, response}; use crate::messages::{ DataConsumerCloseRequest, DataConsumerDumpRequest, DataConsumerGetBufferedAmountRequest, DataConsumerGetStatsRequest, DataConsumerPauseRequest, DataConsumerResumeRequest, @@ -17,6 +16,7 @@ use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionH use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{data_consumer, data_producer, notification, response}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::borrow::Cow; diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index baef69427e..8660a89c92 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -2,7 +2,6 @@ mod tests; use crate::data_structures::{AppData, WebRtcMessage}; -use crate::fbs::{data_producer, response}; use crate::messages::{ DataProducerCloseRequest, DataProducerDumpRequest, DataProducerGetStatsRequest, DataProducerPauseRequest, DataProducerResumeRequest, DataProducerSendNotification, @@ -14,6 +13,7 @@ use crate::worker::{Channel, NotificationError, RequestError}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{data_producer, response}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::error::Error; diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 0098c28bef..817a37cd1a 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -5,7 +5,6 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions}; use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, SctpState}; -use crate::fbs::{direct_transport, notification, response, transport}; use crate::messages::{TransportCloseRequest, TransportSendRtcpNotification}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -23,6 +22,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{direct_transport, notification, response, transport}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 3461a47cc4..e69ee992da 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -5,7 +5,6 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions}; use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, ListenInfo, SctpState, TransportTuple}; -use crate::fbs::{notification, pipe_transport, response, transport}; use crate::messages::{PipeTransportConnectRequest, PipeTransportData, TransportCloseRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -22,6 +21,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{notification, pipe_transport, response, transport}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index d29d2adfcd..8988b6d37b 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -5,7 +5,6 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions}; use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, ListenInfo, SctpState, TransportTuple}; -use crate::fbs::{notification, plain_transport, response, transport}; use crate::messages::{PlainTransportData, TransportCloseRequest, TransportConnectPlainRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -22,6 +21,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{notification, plain_transport, response, transport}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 5b0e1b68fd..b25c40a711 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -3,7 +3,6 @@ mod tests; use crate::consumer::{RtpStreamParams, RtxStreamParams}; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; -use crate::fbs::{notification, producer, response, rtp_parameters, rtp_stream}; use crate::messages::{ ProducerCloseRequest, ProducerDumpRequest, ProducerEnableTraceEventRequest, ProducerGetStatsRequest, ProducerPauseRequest, ProducerResumeRequest, ProducerSendNotification, @@ -18,6 +17,7 @@ use crate::worker::{ use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{notification, producer, response, rtp_parameters, rtp_stream}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index cbab16ca27..feb1d5d012 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -2,7 +2,6 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions, ConsumerType}; use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, BweTraceInfo, RtpPacketTraceInfo, TraceEventDirection}; -use crate::fbs::{response, transport}; use crate::messages::{ TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequest, TransportEnableTraceEventRequest, TransportGetStatsRequest, TransportProduceDataRequest, @@ -22,6 +21,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::HandlerId; use log::{error, warn}; +use mediasoup_sys::fbs::{response, transport}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index ff9630c751..809b91d7dc 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -8,7 +8,6 @@ use crate::data_structures::{ AppData, DtlsParameters, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenInfo, SctpState, TransportTuple, }; -use crate::fbs::{notification, response, transport, web_rtc_transport}; use crate::messages::{ TransportCloseRequest, TransportRestartIceRequest, WebRtcTransportConnectRequest, WebRtcTransportData, @@ -28,6 +27,7 @@ use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; +use mediasoup_sys::fbs::{notification, response, transport, web_rtc_transport}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index e063baa242..e430b3a1f3 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -4,8 +4,8 @@ #[cfg(test)] mod tests; -use crate::fbs::rtp_parameters; use crate::scalability_modes::ScalabilityMode; +use mediasoup_sys::fbs::rtp_parameters; use serde::de::{MapAccess, Visitor}; use serde::ser::SerializeStruct; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; diff --git a/rust/src/sctp_parameters.rs b/rust/src/sctp_parameters.rs index 585369b913..807dafbea8 100644 --- a/rust/src/sctp_parameters.rs +++ b/rust/src/sctp_parameters.rs @@ -1,6 +1,6 @@ //! Collection of SCTP-related data structures that are used to specify SCTP association parameters. -use crate::fbs::sctp_parameters; +use mediasoup_sys::fbs::sctp_parameters; use serde::{Deserialize, Serialize}; /// Number of SCTP streams. diff --git a/rust/src/srtp_parameters.rs b/rust/src/srtp_parameters.rs index e7e90e500b..99bb898cf8 100644 --- a/rust/src/srtp_parameters.rs +++ b/rust/src/srtp_parameters.rs @@ -1,7 +1,7 @@ //! Collection of SRTP-related data structures that are used to specify SRTP encryption/decryption //! parameters. -use crate::fbs::srtp_parameters; +use mediasoup_sys::fbs::srtp_parameters; use serde::{Deserialize, Serialize}; /// SRTP parameters. diff --git a/rust/src/webrtc_server.rs b/rust/src/webrtc_server.rs index fe323d30ba..4750323c56 100644 --- a/rust/src/webrtc_server.rs +++ b/rust/src/webrtc_server.rs @@ -11,7 +11,6 @@ mod tests; use crate::data_structures::{AppData, ListenInfo}; -use crate::fbs::transport; use crate::messages::{WebRtcServerCloseRequest, WebRtcServerDumpRequest}; use crate::transport::TransportId; use crate::uuid_based_wrapper_type; @@ -21,6 +20,7 @@ use async_executor::Executor; use event_listener_primitives::{BagOnce, HandlerId}; use hash_hasher::HashedSet; use log::{debug, error}; +use mediasoup_sys::fbs::transport; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/rust/src/worker.rs b/rust/src/worker.rs index 32c473488f..56766bec13 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs @@ -6,7 +6,6 @@ mod common; mod utils; use crate::data_structures::AppData; -use crate::fbs; use crate::messages::{ WorkerCloseRequest, WorkerCreateRouterRequest, WorkerCreateWebRtcServerRequest, WorkerDumpRequest, WorkerUpdateSettingsRequest, @@ -24,6 +23,7 @@ pub(crate) use common::{SubscriptionHandler, SubscriptionTarget}; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use futures_lite::FutureExt; use log::{debug, error, warn}; +use mediasoup_sys::fbs; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::error::Error; diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index ea24ebe8c3..8dc53c9a76 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -1,4 +1,3 @@ -use crate::fbs::{message, notification, request, response}; use crate::messages::{Notification, Request}; use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers}; use crate::worker::utils; @@ -8,6 +7,7 @@ use atomic_take::AtomicTake; use hash_hasher::HashedMap; use log::{debug, error, trace, warn}; use lru::LruCache; +use mediasoup_sys::fbs::{message, notification, request, response}; use mediasoup_sys::UvAsyncT; use parking_lot::Mutex; use planus::ReadAsRoot; diff --git a/rust/src/worker/common.rs b/rust/src/worker/common.rs index f6ef339ea8..7259809ab2 100644 --- a/rust/src/worker/common.rs +++ b/rust/src/worker/common.rs @@ -1,5 +1,5 @@ -use crate::fbs::notification; use hash_hasher::HashedMap; +use mediasoup_sys::fbs::notification; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::Deserialize; diff --git a/worker/Cargo.toml b/worker/Cargo.toml index c7b3ad6639..9116fc8444 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -9,6 +9,7 @@ documentation = "https://docs.rs/mediasoup-sys" repository = "https://github.com/versatica/mediasoup/tree/v3/worker" include = [ "/deps/libwebrtc", + "/fbs", "/fuzzer/include", "/fuzzer/src", "/include", @@ -28,3 +29,14 @@ include = [ [package.metadata.docs.rs] default-target = "x86_64-unknown-linux-gnu" targets = [] + +[build-dependencies] +planus-codegen = "0.4.0" +planus-translation = "0.4.0" + +[dependencies] +planus = "0.4.0" + +[dependencies.serde] +features = ["derive"] +version = "1.0.190" diff --git a/worker/build.rs b/worker/build.rs index 2caf96525b..8bf0b836fe 100644 --- a/worker/build.rs +++ b/worker/build.rs @@ -1,5 +1,5 @@ -use std::env; use std::process::Command; +use std::{env, fs}; fn main() { if env::var("DOCS_RS").is_ok() { @@ -16,6 +16,35 @@ fn main() { }; let out_dir = env::var("OUT_DIR").unwrap(); + + // Compile Rust flatbuffers + let flatbuffers_declarations = planus_translation::translate_files( + &fs::read_dir("fbs") + .expect("Failed to read `fbs` directory") + .filter_map(|maybe_entry| { + maybe_entry + .map(|entry| { + let path = entry.path(); + if path.extension() == Some("fbs".as_ref()) { + Some(path) + } else { + None + } + }) + .transpose() + }) + .collect::, _>>() + .expect("Failed to collect flatbuffers files"), + ) + .expect("Failed to translate flatbuffers files"); + + fs::write( + format!("{out_dir}/fbs.rs"), + planus_codegen::generate_rust(&flatbuffers_declarations) + .expect("Failed to generate Rust code from flatbuffers"), + ) + .expect("Failed to write generated Rust flatbuffers into fbs.rs"); + // Force forward slashes on Windows too so that is plays well with our dumb `Makefile`. let mediasoup_out_dir = format!("{}/out", out_dir.replace('\\', "/")); diff --git a/worker/src/lib.rs b/worker/src/lib.rs index fe8aae3d16..ad666d36a6 100644 --- a/worker/src/lib.rs +++ b/worker/src/lib.rs @@ -1,5 +1,7 @@ use std::os::raw::{c_char, c_int, c_void}; +include!(concat!(env!("OUT_DIR"), "/fbs.rs")); + #[repr(transparent)] #[derive(Copy, Clone)] pub struct UvAsyncT(pub *const c_void);